• Post Reply Bookmark Topic Watch Topic
  • New Topic

Duplicate Id error is thrown?  RSS feed

 
ramesh kul
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Iam try to submit a jsf page using <h:commandButton>, but iam getting Duplicate Id error. Can any one help me what might the problem?

Thanks
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple that you have a duplicate id in your form. Check the id's that you have given the different elements of your form.

I have sometimes the same problem when I add an new item to my page and try to reload my page. The solution of this problem is close your browser and remove the page from your history and then open the browser again. This problem I experience with FireFox.
 
ramesh kul
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your comments.
The page was working fine unless, i added a custom component to it. Is that will create that problem?
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think so. You can simply test it with removing the component from you page. If it's working fine then you know the problem lays there.

Have you developed your own component or are you using from a library which is developed by others?

At the moment I don't have a lot of practical experience with developing my own. If you're using JSF 1.1. you could upgrade to JSF 1.2. this could solve some duplicate id issues.

The following link gives you some guidelines how to solve the problem


# If the duplicate id is one that you have created: check if there are duplicate components ids in your jsp source code, do not forget the included components.
# If you use the JSTL core tags, forEach, if, choose and when don't forget that the JavaServer Faces tags nested within these tags must have explicit identifiers. In this case you cannot rely on the generated ids.
# Check if you programmatically add components to the component tree without giving them explicit ids. If so you must give them explicit ids.
# Sometimes you only wrestle with this problem during development and it can be solved by creating a new session.


JspException; Duplicate component id: '_id0:_id14', first used in tag:

I hope this helps
 
Tim Holloway
Bartender
Posts: 18716
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"id" is a magic XML attribute. It's usable as a general attribute by apps, but according to the XML specs, it's also meaningful as part of an XML construct.

The ID is intended to be used to uniquely identify an XML element. The "duplicate ID" error indicates that at least one of the elements in your XML is not unique - that some other element has been assigned the exact same ID attribute value.

Having a unique element ID is very helpful, since XML tools can use it to taget operations on that one specific element. It's also very valuable in JSF, since the control ID appears in many JSF messages. If you don't provide an explicit ID, one gets generated for you, but it's almost impossible to match the generated ID back to find which control you misconfigured, so I recommend you always set an explicit ID.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!