A duplicated components id exception is thrown when using diferent subviews.
Well, here is my code:
Default.jsp
<f:view>
<h:form id="MainForm" enctype="multipart/form-data"
styleClass="height-100">
...some components...
<h:panelGrid columns="1" width="100%"
rendered="#{default.eventsDefined}">
<jsp:include page="DetailsView.jsp" />
</h:panelGrid>
</h:form>
</f:view>
DetailsView.jsp:
<%
DefaultPageBean defaultPage = (DefaultPageBean) javax.faces.context.FacesContext
.getCurrentInstance().getApplication()
.getVariableResolver().resolveVariable(
javax.faces.context.FacesContext
.getCurrentInstance(),
"default");
%>
<f:subview id="detailsView">
<f:loadBundle
basename="com.myproject.tests.webapp.resources.Messages"
var="msg" />
<h:panelGrid columns="1" columnClasses="defaultToolBar"
styleClass="width-100" cellpadding="0" cellspacing="0">
<h:panelGroup cellpadding="2">
<h:commandLink id="lnkShowAnalysis"
action="#{details.showAnalysisView}">
<h:outputText value="#{msg.analysis}" />
</h:commandLink>
<h:commandLink id="lnkShowTemplates"
action="#{details.showTemplatesView}">
<h:outputText value="#{msg.templates}"
/>
</h:commandLink>
</h:panelGroup>
</h:panelGrid>
<h:panelGrid columns="1" styleClass="width-100" cellpadding="0"
cellspacing="0">
<jsp:include page="<%= defaultPage.getSecondaryView() %>" />
</h:panelGrid>
</f:subview>
The method getSecondaryView() returns a relative path of another jsp file.
The methods showAnalysisView() and showTemplatesView() assigns
specific relative paths to different jsp: When lnkShowAnalysis is
clicked, DetailsViewBackingBean assigns as a secondaryView from
DefaultPageBackingBean the relative path for analysis.jsp. As previous
situation, when lnkShowTemplates is clicked, templates.jsp will be
shown.
When templates.jsp is shown and I click over lnkShowAnalysis, an error
of duplicated ids is throwed. For avoiding that I set specific ids to
all components from all jsp, but it causes strange behaviour: The
secondary view is shown alternatively (it means that if it's shown on
current request, on next request will not be shown and viceversa).
Also, I noticed that the number of components into child subview are
involved in problem: If I have 4 components declared on secondary view
and I remove one of them the exception is not throwed. Furthermore, if
I declare more components than 3 in the same view the exception is
ever shown.
The number of components in child subviews are limited by parent
number of declared components?
After reading some posts I think that my problem could be resolved
applying one of these solutions:
http://forum.java.sun.com/thread.jspa?threadID=524925&messageID=3642843
but is possible to solve this problem without setting as transient the
context into decode-methods or without creating a session backing bean
with method createUniqueId()?
Sorry for my english,
Jordi