Hi all: 

Am working through the second of the JSF for nonbelievers article and have 
found a weird error while constructing one of my jsps. I have two links 
for sorting by descending and ascending items in a table. It seems like 
the first link works great, but the second link always gives me a 
"Duplicate component ID" error.

When links are arranged with "D" first and "A" second: 
1. Click on "D" multiple times: Works good - sorts the list in descending 
order and brings back view fine.
2. Click on "A". Get: javax.servlet.ServletException: 
javax.servlet.jsp.JspException: Duplicate component ID 
'_id0:items:descendingtitleId' found in view.

When links are arranged with "A" first and "D" next, the mirror image 
happens:
1. Click on A multiple times: Works good - sorts the list in ascending 
order and brings back view fine.
2. Click on "D": Get javax.servlet.jsp.JspException: Duplicate component 
ID '_id0:items:ascendingtitleId' found in view.

code in jsp is:
        <h:form>
                <h:dataTable id="items" value="#{CDManagerBean.cds}" var=
"cd"
                        rowClasses="oddRow, evenRow" headerClass=
"tableHeader">

                        <h:column id="aColumn">
                                <f:facet name="header">
                                        <h:panelGroup id="aPanelGroupId">
                                                <h:outputText value=
"Title" id="anOutputText"/>
                                                <f:verbatim>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</f:verbatim>
                                                <f:subview id=
"ascendingtitleId">
                                                        <h:commandLink 
action="#{CDManagerBean.sortTitleAsc}" id="sortAscCommandId">
                                                                <
h:outputText id="ascTitle" value="Asc" />
                                                        </h:commandLink>
                                                </f:subview>
                                                <f:verbatim>&nbsp;</
f:verbatim>
                                                <f:subview id=
"descendingtitleId">
                                                        <h:commandLink 
action="#{CDManagerBean.sortTitleDec}" id="sortDescCommandId">
                                                                <
h:outputText id="somedescendingTitleId" value="Dsc" />
                                                        </h:commandLink>
                                                </f:subview>
                                        </h:panelGroup>
                                </f:facet>

 I have googled and found this: 
http://www.jsf-faq.com/faqs/faces-exception.html#104 and also 
http://forum.java.sun.com/thread.jspa?threadID=524925&tstart=0. 

The advice I have got from teh baove links is that I need to give 
different Ids to my components and that I should be careful while "mixing" 
JSF and "<c: tags. Also to put links within <f:subview> tags. Well, I dont 
have any <c: tags at all and I have id-ed every compnent in sight and 
placed the links within the <f:subview> but have had no luck. Restarted 
the server, changed the order of clicking the links and no matter - the 
link which is *visually* second causes trouble but the first one works 
just fine. Does exactly the same thing in both Firefox and IE.

Any help will be most gratefully accepted!
Geeta

Reply via email to