File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Duplicate Component Id Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Duplicate Component Id" Watch "Duplicate Component Id" New topic

Duplicate Component Id

Chris Voge
Ranch Hand

Joined: Jul 25, 2005
Posts: 34
Just wanted to share how I fixed a
"Duplicate Component Id" error I was receiving.

From the research I did, all JSF components are
kept in a component tree with all the ID's preserved
from page to page. When I was dynamically adding
a new SelectItem to a SelectOneMenu, it was trying
to assign an Id that was already on the component

I discovered a method called setTransient(boolean)
that controls whether to either preserve my Faces
jsp pages and or basically load the page from scratch
assigning new Id's to whatever components are loaded.
A value of false loads the page from scratch.

I hope this all makes sense.

It was pain to resolve, but it made me feel good

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Just on a related note, aside from it's method in JSF you can use the transient keyword on any property of a persisted object to keep that property from being persisted. For example

If you persist this class in any way, the password does not get persisted with it. So that is, in escence, what that method is doing for you.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: Duplicate Component Id
It's not a secret anymore!