• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Duplicate Component Id

 
Chris Voge
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
tree.

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

Chris
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic