• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JSF- Duplicate Component Id Exception

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do anyone ever faced the problem for the Duplicate Component ID while the JSF components are rendered ? Please help me if anybody figured out the exact reason behind this problem.
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a well knowned bug.

Not sure about it's exact cause or remedy
 
Author
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Duplicate ids arise because of the manner in which JSP and JSF interact. Two typical scenarios for this error are when you are conditionally specifying components inside <c:if> or <c:choose>, or when you programatically add components to the component tree without giving them explicit ids.

Here is an article that explains what the discontinuities are between JSF and JSP. Rather than trying to troubleshoot your problem here in the forum, skim over that article and see if anything pertains to your situation.

Let us know what you find out!
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I too got this error once. I was modifying the ID of command link component from the backing bean, and the child element of command link i.e. an outputText component started giving me this error.

I put whole of this bunch inside a datatable, the error was gone.
:roll:
 
S Mishra
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Geary.. i have not read the document before....

But this behaviour is also observed when I suppose this is not the JSP and JSF rendering issue. Consider this scenario:

I have a JSP test.jsp with a datatable dtable binded to a backing bean element testTable in bean Test.java. This table contains a collection of command links in it. It also has a Update button which updates some values.
On click of Update it opens a new update pop up Dialog.

Now Update Dialog has a JSP say updateTest.jsp using the same bean Test.Java from session. It also has another Table updateTable mapped to the same backing bean element testTable. Now if you use any command link in this table it always give you the Duplicate ID exception.

In this scenario - JSP's are different, all Command Links are also bound by a data table, but the bean is same. The reason for keeping the same bean is that both update and test jsp has the same fields.

The problem eliminates if I use a different binding element to table -- say updateTable in the Bean, or if I remove the command links. It only gives problem when you use command links inside a table. It works fine for Input Text and Output Text.

I hope the problem is clear to you...
 
David Geary
Author
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can carve out a small code sample that illustrates the problem, I'll take a look.
 
S Mishra
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Geary,

find the code below....

Test.jsp....
____________________________________________________________________
<div class="divTable" style="height: 90px"><h ataTable
width="100%" value="#{Test.testData}"
var="currentRow" rowClasses="rowOdd,rowEven"
columnClasses="column" headerClass="header" border="1"
styleClass="complexTable" cellpadding="2" cellspacing="0"
binding="#{Test.testTable}">
<h:column>
<h:commandLink>
<h utputText value="#{currentRow.name}" style="width:125px;"/>
</h:commandLink>
</h:column>
<h:column>
<h:commandLink>
<h utputText value="#{currentRow.type}" style="width:125px;"/>
</h:commandLink>
</h:column>
</h ataTable></div>

UpdateTest.jsp....
____________________________________________________________________
<div class="divTable" style="height: 90px"><h ataTable
width="100%" value="#{Test.updateData}"
var="currentRow" rowClasses="rowOdd,rowEven"
columnClasses="column" headerClass="header" border="1"
styleClass="complexTable" cellpadding="2" cellspacing="0"
binding="#{Test.testTable}"> -- same binding table....
<h:column>
<h:commandLink>
<h utputText value="#{currentRow.name}" style="width:125px;"/>
</h:commandLink>
</h:column>
<h:column>
<h:inputText value="#{currentRow.newName}"/>
</h:column>
</h ataTable></div>

------------------------------------------------------------------------

Test.java
________________________________________________________________________

private HtmlDataTable testTable;
private List testData;
private List updateData;

Both testData and updateData are collections of TestDetails Object having fields,

private String name;
private String newName;
private String type;
private String newType;

---------------------------------------------------------------------

I think this might will clear you my problem. Currently I have used different binding for both teh tables in test.jsp and updateTest.jsp to avoid the Duplicate ID exception.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic