You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Travis Reeder <tr...@gmail.com> on 2006/03/28 02:08:45 UTC
Re: Duplicate id : _id1. Child could not be added.
Definitely want to use rendered vs c:if. JSF doesn't see the "if" so it
will assign an id to the next component it sees the first time around, and
if that changes next reload, the component that JSF hasn't seen will get
assigned an id that may have already been used. Something like that
anyways. ;)
Travis
On 3/27/06, Murray Brandon <mu...@hotmagna.com> wrote:
>
> Hi all,
>
> I've been thinking about what I might be doing that's different from
> everyone else.
>
> 1) Currently I use a single form for the entire application (my form is
> defined at the root only) and my application is in a single large
> component tree with many facelet includes so the display is controlled
> by <c:if> tags.
> 2) My form uses prependId="false" - not sure the signficance of setting
> this to true.
>
> <h:form id="appform" prependId="false">
>
> 3) I don't define any components IDs at all - after all, why should I
> define an ID unless I specifically need to refer to that component
> again? That would be just pointless busy work.
> 4) All my common controls I define in separate .xhtml compositions so I
> can't give them unique IDs without a duplicate ID (or does the ID get
> prepended with the parent component ID?). eg. date.xhtml below
>
> <ui:composition>
> <!-- required parameters -->
> <!-- property -->
>
> <!-- optional parameters -->
> <c:if test="${empty required}">
> <c:set var="required" value="false" />
> </c:if>
> <c:if test="${empty disabled}">
> <c:set var="disabled" value="false" />
> </c:if>
> <c:if test="${empty readOnly}">
> <c:set var="readOnly" value="false" />
> </c:if>
>
> <c:if test="${not empty label}">
> <h:outputText value="${label}" />
> </c:if>
>
> <t:inputCalendar monthYearRowClass="yearMonthHeader"
> weekRowClass="weekHeader"
> currentDayCellClass="currentDayCell"
> popupDateFormat="dd/MM/yyyy"
> value="#{property['value']}"
> renderAsPopup="true"
> popupTodayString="Today is :"
> popupWeekString="Week"
> renderPopupButtonAsImage="true" />
> </ui:composition>
>
> 5) I'm using a mix of ADF/Facelets/Tomahawk in the MyFaces impl and
> given that it happens often but intermittently, perhaps this comment
> applies: "Are you using the c:if/c:/choose JSTL tags with facelets? That
> was my problem. MyFaces doesn't appreciate my current view changing on
> postback to the same view (non-navigation)".
>
> 6) Should I be using rendered="#{condition}" instead of the JSTL <c:if
> tags to avoid confusing MyFaces? To preserve memory and performance I
> actually don't want an include to be compiled at all unless it needs to
> be displayed.
>
> Sorry to post to both groups but it could be relevant to both.
>
> Regards, Murray
>
> PS. versions of libs:
> 10,823 adf-facelets.jar
> 683,633 adf-faces-api-ea20-SNAPSHOT.jar
> 3,122,625 adf-faces-impl-ea20-SNAPSHOT.jar
> 48,742 common-annotations.jar
> 188,671 commons-beanutils-1.7.0.jar
> 46,725 commons-codec-1.3.jar
> 559,366 commons-collections-3.1.jar
> 168,446 commons-digester-1.6.jar
> 112,341 commons-el-1.0.jar
> 31,825 commons-fileupload-1.1.jar
> 65,621 commons-io-1.2.jar
> 207,723 commons-lang-2.1.jar
> 38,015 commons-logging-1.0.4.jar
> 26,089 el-api.jar
> 96,983 el-ri.jar
> 241,801 jsf-facelets1012.jar
> 50,491 jsp-api.jar
> 16,923 jstl-1.1.0.jar
> 252,186 myfaces-api-1.1.3-SNAPSHOT.jar
> 516,661 myfaces-impl-1.1.3-SNAPSHOT.jar
> 15,420 portlet.jar
> 188,993 serializer.jar
> 1,231,963 tomahawk-1.1.2-SNAPSHOT.jar
> 3,078,601 xalan.jar
> 1,203,860 xercesImpl.jar
> 194,205 xml-apis.jar
> 12,398,732 bytes
>
> -----Original Message-----
> From: Murray Brandon [mailto:murray@hotmagna.com]
> Sent: Monday, March 27, 2006 12:08 PM
> To: users@facelets.dev.java.net
> Subject: Duplicate id : _id1. Child could not be added.
>
>
> The following xhtml fails when I include it using ui:include.
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:f="http://java.sun.com/jsf/core"
> xmlns:h="http://java.sun.com/jsf/html"
> xmlns:ui="http://java.sun.com/jsf/facelets"
> xmlns:c="http://java.sun.com/jstl/core"
> >
> <ui:composition>
> <h:outputText value="Well well well" />
> <h:commandButton id="b" type="submit" action="success"
> value="Submit" />
> </ui:composition>
> </html>
>
>
> This fails, however if I change the outputText to read
> <h:outputText id="a" value="Well well well" />
> it works fine.
>
>
> I'm including using a <c:if snippet in another file/component.
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:f="http://java.sun.com/jsf/core"
> xmlns:h="http://java.sun.com/jsf/html"
> xmlns:ui="http://java.sun.com/jsf/facelets"
> xmlns:c="http://java.sun.com/jstl/core"
> >
> :
> <ui:component>
> :
> :
> <h:panelGrid id="pagePanels" width="100%">
> <c:if test="#{ui.tabPanel.selection == 'user'}">
> <ui:include src="file:userSearchPanel.xhtml" />
> </c:if>
> <c:if test="#{ui.tabPanel.selection == 'rules'}">
> <ui:include src="file:panel1.xhtml" />
> </c:if>
> <c:if test="#{ui.tabPanel.selection == 'role'}">
> <ui:include src="file:panel2.xhtml" />
> </c:if>
> <c:if test="#{ui.tabPanel.selection == 'resources'}">
> <ui:include src="file:controlTest.xhtml" />
> </c:if>
> <c:if test="#{ui.tabPanel.selection == 'system'}">
> <ui:include src="file:examples2.xhtml" />
> </c:if>
> </h:panelGrid>
>
> I'd rather not have to define unique ID's for each of my compositions as
> I'll be re-using them a lot. Anyone got ideas what I've done wrong?
>
> Regards, Murray
>
>
Re: Duplicate id : _id1. Child could not be added - lazy loading xhtml
Posted by Travis Reeder <tr...@gmail.com>.
You could try using <subview>s within the if's, that *might* work.
Travis
On 3/27/06, Murray Brandon <mu...@hotmagna.com> wrote:
>
> Thanks Travis,
>
> From the sound of it, massive warnings need to be placed around references
> to the <c:if> to stop people using it if it doesn't work, or is it just when
> coupled with include type tags?
> I'd like to read more on the subject if anyone has some doco on how it
> works.
>
> With a component tree of some 600 included panels, I absolutely need the
> <c:if> or similar to ensure lazy compilation in Facelets.
> Is the alternative to force unique IDs on all components within the
> included files? (seems horrible).
>
> I can't change the <c:if> to a rendered= parameter, because I am lazy
> loading one of the 600 panels I'm using.
>
> <c:if test="#{ui.tabPanel.selection == 'user'}">
> <ui:include src="file:userSearchPanel.xhtml"/>
> </c:if>
>
> There is currently not a "rendered" property to set on the facelets
> <ui:include> tag. eg.
> <ui:include src="file:userSearchPanel.xhtml" rendered="#{
> ui.tabPanel.selection == 'user'}"/>
>
> Would such a "rendered" property work? I'm thinking no because the
> facelets are compiled earlier.
>
> I want to avoid creation of the Facelet until the very last moment, given
> that 600 panels would make the app just sit there for half an hour on
> startup
> and at any time only 10% of the screens will be in use.
>
> If I change the above to be:
>
> <h:panelGrid columns="1" rendered="false">
> <ui:include src="file:userSearchPanel.xhtml" />
> </h:panelGrid>
>
> The facelet gets compiled even when the panelGrid isn't being rendered:
>
> Mar 28, 2006 4:45:11 AM com.sun.facelets.impl.DefaultFaceletFactorycreateFacelet
> FINE: Creating Facelet for:
> file:/devel/playpen/aui/data/screens/userSearchPanel.xhtml
>
> Regards, Murray
>
> -----Original Message-----
> *From:* Travis Reeder [mailto:treeder@gmail.com]
> *Sent:* Tuesday, March 28, 2006 10:09 AM
> *To:* MyFaces Discussion
> *Subject:* Re: Duplicate id : _id1. Child could not be added.
>
> Definitely want to use rendered vs c:if. JSF doesn't see the "if" so it
> will assign an id to the next component it sees the first time around, and
> if that changes next reload, the component that JSF hasn't seen will get
> assigned an id that may have already been used. Something like that
> anyways. ;)
>
> Travis
>
> On 3/27/06, Murray Brandon <mu...@hotmagna.com> wrote:
> >
> > Hi all,
> >
> > I've been thinking about what I might be doing that's different from
> > everyone else.
> >
> > 1) Currently I use a single form for the entire application (my form is
> > defined at the root only) and my application is in a single large
> > component tree with many facelet includes so the display is controlled
> > by <c:if> tags.
> > 2) My form uses prependId="false" - not sure the signficance of setting
> > this to true.
> >
> > <h:form id="appform" prependId="false">
> >
> > 3) I don't define any components IDs at all - after all, why should I
> > define an ID unless I specifically need to refer to that component
> > again? That would be just pointless busy work.
> > 4) All my common controls I define in separate .xhtml compositions so I
> > can't give them unique IDs without a duplicate ID (or does the ID get
> > prepended with the parent component ID?). eg. date.xhtml below
> >
> > <ui:composition>
> > <!-- required parameters -->
> > <!-- property -->
> >
> > <!-- optional parameters -->
> > <c:if test="${empty required}">
> > <c:set var="required" value="false" />
> > </c:if>
> > <c:if test="${empty disabled}">
> > <c:set var="disabled" value="false" />
> > </c:if>
> > <c:if test="${empty readOnly}">
> > <c:set var="readOnly" value="false" />
> > </c:if>
> >
> > <c:if test="${not empty label}">
> > <h:outputText value="${label}" />
> > </c:if>
> >
> > <t:inputCalendar monthYearRowClass="yearMonthHeader"
> > weekRowClass="weekHeader"
> > currentDayCellClass="currentDayCell"
> > popupDateFormat="dd/MM/yyyy"
> > value="#{property['value']}"
> > renderAsPopup="true"
> > popupTodayString="Today is :"
> > popupWeekString="Week"
> > renderPopupButtonAsImage="true" />
> > </ui:composition>
> >
> > 5) I'm using a mix of ADF/Facelets/Tomahawk in the MyFaces impl and
> > given that it happens often but intermittently, perhaps this comment
> > applies: "Are you using the c:if/c:/choose JSTL tags with facelets? That
> >
> > was my problem. MyFaces doesn't appreciate my current view changing on
> > postback to the same view (non-navigation)".
> >
> > 6) Should I be using rendered="#{condition}" instead of the JSTL <c:if
> > tags to avoid confusing MyFaces? To preserve memory and performance I
> > actually don't want an include to be compiled at all unless it needs to
> > be displayed.
> >
> > Sorry to post to both groups but it could be relevant to both.
> >
> > Regards, Murray
> >
> > PS. versions of libs:
> > 10,823 adf-facelets.jar
> > 683,633 adf-faces-api-ea20-SNAPSHOT.jar
> > 3,122,625 adf-faces-impl-ea20-SNAPSHOT.jar
> > 48,742 common-annotations.jar
> > 188,671 commons-beanutils-1.7.0.jar
> > 46,725 commons-codec-1.3.jar
> > 559,366 commons-collections-3.1.jar
> > 168,446 commons-digester-1.6.jar
> > 112,341 commons-el-1.0.jar
> > 31,825 commons-fileupload-1.1.jar
> > 65,621 commons-io-1.2.jar
> > 207,723 commons-lang-2.1.jar
> > 38,015 commons-logging-1.0.4.jar
> > 26,089 el-api.jar
> > 96,983 el-ri.jar
> > 241,801 jsf-facelets1012.jar
> > 50,491 jsp-api.jar
> > 16,923 jstl-1.1.0.jar
> > 252,186 myfaces-api-1.1.3-SNAPSHOT.jar
> > 516,661 myfaces-impl-1.1.3-SNAPSHOT.jar
> > 15,420 portlet.jar
> > 188,993 serializer.jar
> > 1,231,963 tomahawk-1.1.2-SNAPSHOT.jar
> > 3,078,601 xalan.jar
> > 1,203,860 xercesImpl.jar
> > 194,205 xml-apis.jar
> > 12,398,732 bytes
> >
> > -----Original Message-----
> > From: Murray Brandon [mailto:murray@hotmagna.com]
> > Sent: Monday, March 27, 2006 12:08 PM
> > To: users@facelets.dev.java.net
> > Subject: Duplicate id : _id1. Child could not be added.
> >
> >
> > The following xhtml fails when I include it using ui:include.
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml"
> > xmlns:f="http://java.sun.com/jsf/core"
> > xmlns:h=" http://java.sun.com/jsf/html"
> > xmlns:ui="http://java.sun.com/jsf/facelets"
> > xmlns:c=" http://java.sun.com/jstl/core"
> > >
> > <ui:composition>
> > <h:outputText value="Well well well" />
> > <h:commandButton id="b" type="submit" action="success"
> > value="Submit" />
> > </ui:composition>
> > </html>
> >
> >
> > This fails, however if I change the outputText to read
> > <h:outputText id="a" value="Well well well" />
> > it works fine.
> >
> >
> > I'm including using a <c:if snippet in another file/component.
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> > " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml"
> > xmlns:f=" http://java.sun.com/jsf/core"
> > xmlns:h="http://java.sun.com/jsf/html"
> > xmlns:ui="http://java.sun.com/jsf/facelets "
> > xmlns:c="http://java.sun.com/jstl/core"
> > >
> > :
> > <ui:component>
> > :
> > :
> > <h:panelGrid id="pagePanels" width="100%">
> > <c:if test="#{ui.tabPanel.selection == 'user'}">
> > <ui:include src="file:userSearchPanel.xhtml" />
> > </c:if>
> > <c:if test="#{ ui.tabPanel.selection == 'rules'}">
> > <ui:include src="file:panel1.xhtml" />
> > </c:if>
> > <c:if test="#{ui.tabPanel.selection == 'role'}">
> > <ui:include src="file:panel2.xhtml" />
> > </c:if>
> > <c:if test="#{ui.tabPanel.selection == 'resources'}">
> > <ui:include src="file: controlTest.xhtml" />
> > </c:if>
> > <c:if test="#{ui.tabPanel.selection == 'system'}">
> > <ui:include src="file:examples2.xhtml" />
> > </c:if>
> > </h:panelGrid>
> >
> > I'd rather not have to define unique ID's for each of my compositions as
> > I'll be re-using them a lot. Anyone got ideas what I've done wrong?
> >
> > Regards, Murray
> >
> >
>
RE: Duplicate id : _id1. Child could not be added - lazy loading xhtml
Posted by Sonja Löhr <so...@arcor.de>.
It's not all about <c:if> ....
Even without <c:if> around components and includes, I always face the
duplicated Id problem when including some tomahawk component such as a
panelnavigation2. My application used tiles with myfaces and I thought I
could get rid of the duplicated IDs when switching to facelets ( I somehow
expected facelets to first do all including, templating and so on and then
creating ids and rendering the view. But it's even worse than before.
Here are the steps I take if the problem reoccurs:
a) Whenever not really necessary, I removed "binding" atts from lists and
navigation components - helps a bit
b) Add more IDs Source tags are a good way to get Ids on subcomponents if
you pass some base string - helps a bit
c) I reintroduced <f:subview> to include my panelnavigations, in (nearly)
each template client, such that the subview's ids change.
I would be glad if someone at least could explain what is happening if the
app complains that "nav3" is duplicated. I use "rendered" and I use
"visibleOnUserRole", but somehow myfaces does mix up subsequent views into
one ??
What about the RI (together with facelets and tomahawk) ? Does it produce
duplicated Ids as well?
Thanks,
sonja
_____
From: Murray Brandon [mailto:murray@hotmagna.com]
Sent: Dienstag, 28. März 2006 07:21
To: 'MyFaces Discussion'; users@facelets.dev.java.net
Subject: RE: Duplicate id : _id1. Child could not be added - lazy loading
xhtml
Thanks Travis,
>From the sound of it, massive warnings need to be placed around references
to the <c:if> to stop people using it if it doesn't work, or is it just when
coupled with include type tags?
I'd like to read more on the subject if anyone has some doco on how it
works.
With a component tree of some 600 included panels, I absolutely need the
<c:if> or similar to ensure lazy compilation in Facelets.
Is the alternative to force unique IDs on all components within the included
files? (seems horrible).
I can't change the <c:if> to a rendered= parameter, because I am lazy
loading one of the 600 panels I'm using.
<c:if test="#{ui.tabPanel.selection == 'user'}">
<ui:include src="file:userSearchPanel.xhtml"/>
</c:if>
There is currently not a "rendered" property to set on the facelets
<ui:include> tag. eg.
<ui:include src="file:userSearchPanel.xhtml"
rendered="#{ui.tabPanel.selection == 'user'}"/>
Would such a "rendered" property work? I'm thinking no because the facelets
are compiled earlier.
I want to avoid creation of the Facelet until the very last moment, given
that 600 panels would make the app just sit there for half an hour on
startup
and at any time only 10% of the screens will be in use.
If I change the above to be:
<h:panelGrid columns="1" rendered="false">
<ui:include src="file:userSearchPanel.xhtml" />
</h:panelGrid>
The facelet gets compiled even when the panelGrid isn't being rendered:
Mar 28, 2006 4:45:11 AM com.sun.facelets.impl.DefaultFaceletFactory
createFacelet
FINE: Creating Facelet for:
file:/devel/playpen/aui/data/screens/userSearchPanel.xhtml
Regards, Murray
-----Original Message-----
From: Travis Reeder [mailto:treeder@gmail.com]
Sent: Tuesday, March 28, 2006 10:09 AM
To: MyFaces Discussion
Subject: Re: Duplicate id : _id1. Child could not be added.
Definitely want to use rendered vs c:if. JSF doesn't see the "if" so it
will assign an id to the next component it sees the first time around, and
if that changes next reload, the component that JSF hasn't seen will get
assigned an id that may have already been used. Something like that
anyways. ;)
Travis
On 3/27/06, Murray Brandon <mu...@hotmagna.com> wrote:
Hi all,
I've been thinking about what I might be doing that's different from
everyone else.
1) Currently I use a single form for the entire application (my form is
defined at the root only) and my application is in a single large
component tree with many facelet includes so the display is controlled
by <c:if> tags.
2) My form uses prependId="false" - not sure the signficance of setting
this to true.
<h:form id="appform" prependId="false">
3) I don't define any components IDs at all - after all, why should I
define an ID unless I specifically need to refer to that component
again? That would be just pointless busy work.
4) All my common controls I define in separate .xhtml compositions so I
can't give them unique IDs without a duplicate ID (or does the ID get
prepended with the parent component ID?). eg. date.xhtml below
<ui:composition>
<!-- required parameters -->
<!-- property -->
<!-- optional parameters -->
<c:if test="${empty required}">
<c:set var="required" value="false" />
</c:if>
<c:if test="${empty disabled}">
<c:set var="disabled" value="false" />
</c:if>
<c:if test="${empty readOnly}">
<c:set var="readOnly" value="false" />
</c:if>
<c:if test="${not empty label}">
<h:outputText value="${label}" />
</c:if>
<t:inputCalendar monthYearRowClass="yearMonthHeader"
weekRowClass="weekHeader"
currentDayCellClass="currentDayCell"
popupDateFormat="dd/MM/yyyy"
value="#{property['value']}"
renderAsPopup="true"
popupTodayString="Today is :"
popupWeekString="Week"
renderPopupButtonAsImage="true" />
</ui:composition>
5) I'm using a mix of ADF/Facelets/Tomahawk in the MyFaces impl and
given that it happens often but intermittently, perhaps this comment
applies: "Are you using the c:if/c:/choose JSTL tags with facelets? That
was my problem. MyFaces doesn't appreciate my current view changing on
postback to the same view (non-navigation)".
6) Should I be using rendered="#{condition}" instead of the JSTL <c:if
tags to avoid confusing MyFaces? To preserve memory and performance I
actually don't want an include to be compiled at all unless it needs to
be displayed.
Sorry to post to both groups but it could be relevant to both.
Regards, Murray
PS. versions of libs:
10,823 adf-facelets.jar
683,633 adf-faces-api-ea20-SNAPSHOT.jar
3,122,625 adf-faces-impl-ea20-SNAPSHOT.jar
48,742 common-annotations.jar
188,671 commons-beanutils-1.7.0.jar
46,725 commons-codec-1.3.jar
559,366 commons-collections-3.1.jar
168,446 commons-digester-1.6.jar
112,341 commons-el-1.0.jar
31,825 commons-fileupload-1.1.jar
65,621 commons-io-1.2.jar
207,723 commons-lang-2.1.jar
38,015 commons-logging-1.0.4.jar
26,089 el-api.jar
96,983 el-ri.jar
241,801 jsf-facelets1012.jar
50,491 jsp-api.jar
16,923 jstl-1.1.0.jar
252,186 myfaces-api-1.1.3-SNAPSHOT.jar
516,661 myfaces-impl-1.1.3-SNAPSHOT.jar
15,420 portlet.jar
188,993 serializer.jar
1,231,963 tomahawk-1.1.2-SNAPSHOT.jar
3,078,601 xalan.jar
1,203,860 xercesImpl.jar
194,205 xml-apis.jar
12,398,732 bytes
-----Original Message-----
From: Murray Brandon [mailto:murray@hotmagna.com]
Sent: Monday, March 27, 2006 12:08 PM
To: users@facelets.dev.java.net
Subject: Duplicate id : _id1. Child could not be added.
The following xhtml fails when I include it using ui:include.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h=" http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c=" <http://java.sun.com/jstl/core>
http://java.sun.com/jstl/core"
>
<ui:composition>
<h:outputText value="Well well well" />
<h:commandButton id="b" type="submit" action="success"
value="Submit" />
</ui:composition>
</html>
This fails, however if I change the outputText to read
<h:outputText id="a" value="Well well well" />
it works fine.
I'm including using a <c:if snippet in another file/component.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
" <http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f=" <http://java.sun.com/jsf/core>
http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets
<http://java.sun.com/jsf/facelets> "
xmlns:c="http://java.sun.com/jstl/core"
>
:
<ui:component>
:
:
<h:panelGrid id="pagePanels" width="100%">
<c:if test="#{ui.tabPanel.selection == 'user'}">
<ui:include src="file:userSearchPanel.xhtml" />
</c:if>
<c:if test="#{ ui.tabPanel.selection == 'rules'}">
<ui:include src="file:panel1.xhtml" />
</c:if>
<c:if test="#{ui.tabPanel.selection == 'role'}">
<ui:include src="file:panel2.xhtml" />
</c:if>
<c:if test="#{ui.tabPanel.selection == 'resources'}">
<ui:include src="file: controlTest.xhtml" />
</c:if>
<c:if test="#{ui.tabPanel.selection == 'system'}">
<ui:include src="file:examples2.xhtml" />
</c:if>
</h:panelGrid>
I'd rather not have to define unique ID's for each of my compositions as
I'll be re-using them a lot. Anyone got ideas what I've done wrong?
Regards, Murray
RE: Duplicate id : _id1. Child could not be added - lazy loading xhtml
Posted by Murray Brandon <mu...@hotmagna.com>.
Thanks Travis,
>From the sound of it, massive warnings need to be placed around
references to the <c:if> to stop people using it if it doesn't work, or
is it just when coupled with include type tags?
I'd like to read more on the subject if anyone has some doco on how it
works.
With a component tree of some 600 included panels, I absolutely need the
<c:if> or similar to ensure lazy compilation in Facelets.
Is the alternative to force unique IDs on all components within the
included files? (seems horrible).
I can't change the <c:if> to a rendered= parameter, because I am lazy
loading one of the 600 panels I'm using.
<c:if test="#{ui.tabPanel.selection == 'user'}">
<ui:include src="file:userSearchPanel.xhtml"/>
</c:if>
There is currently not a "rendered" property to set on the facelets
<ui:include> tag. eg.
<ui:include src="file:userSearchPanel.xhtml"
rendered="#{ui.tabPanel.selection == 'user'}"/>
Would such a "rendered" property work? I'm thinking no because the
facelets are compiled earlier.
I want to avoid creation of the Facelet until the very last moment,
given that 600 panels would make the app just sit there for half an hour
on startup
and at any time only 10% of the screens will be in use.
If I change the above to be:
<h:panelGrid columns="1" rendered="false">
<ui:include src="file:userSearchPanel.xhtml" />
</h:panelGrid>
The facelet gets compiled even when the panelGrid isn't being rendered:
Mar 28, 2006 4:45:11 AM com.sun.facelets.impl.DefaultFaceletFactory
createFacelet
FINE: Creating Facelet for:
file:/devel/playpen/aui/data/screens/userSearchPanel.xhtml
Regards, Murray
-----Original Message-----
From: Travis Reeder [mailto:treeder@gmail.com]
Sent: Tuesday, March 28, 2006 10:09 AM
To: MyFaces Discussion
Subject: Re: Duplicate id : _id1. Child could not be added.
Definitely want to use rendered vs c:if. JSF doesn't see the "if" so it
will assign an id to the next component it sees the first time around,
and if that changes next reload, the component that JSF hasn't seen will
get assigned an id that may have already been used. Something like that
anyways. ;)
Travis
On 3/27/06, Murray Brandon <mu...@hotmagna.com> wrote:
Hi all,
I've been thinking about what I might be doing that's different from
everyone else.
1) Currently I use a single form for the entire application (my form is
defined at the root only) and my application is in a single large
component tree with many facelet includes so the display is controlled
by <c:if> tags.
2) My form uses prependId="false" - not sure the signficance of setting
this to true.
<h:form id="appform" prependId="false">
3) I don't define any components IDs at all - after all, why should I
define an ID unless I specifically need to refer to that component
again? That would be just pointless busy work.
4) All my common controls I define in separate .xhtml compositions so I
can't give them unique IDs without a duplicate ID (or does the ID get
prepended with the parent component ID?). eg. date.xhtml below
<ui:composition>
<!-- required parameters -->
<!-- property -->
<!-- optional parameters -->
<c:if test="${empty required}">
<c:set var="required" value="false" />
</c:if>
<c:if test="${empty disabled}">
<c:set var="disabled" value="false" />
</c:if>
<c:if test="${empty readOnly}">
<c:set var="readOnly" value="false" />
</c:if>
<c:if test="${not empty label}">
<h:outputText value="${label}" />
</c:if>
<t:inputCalendar monthYearRowClass="yearMonthHeader"
weekRowClass="weekHeader"
currentDayCellClass="currentDayCell"
popupDateFormat="dd/MM/yyyy"
value="#{property['value']}"
renderAsPopup="true"
popupTodayString="Today is :"
popupWeekString="Week"
renderPopupButtonAsImage="true" />
</ui:composition>
5) I'm using a mix of ADF/Facelets/Tomahawk in the MyFaces impl and
given that it happens often but intermittently, perhaps this comment
applies: "Are you using the c:if/c:/choose JSTL tags with facelets? That
was my problem. MyFaces doesn't appreciate my current view changing on
postback to the same view (non-navigation)".
6) Should I be using rendered="#{condition}" instead of the JSTL <c:if
tags to avoid confusing MyFaces? To preserve memory and performance I
actually don't want an include to be compiled at all unless it needs to
be displayed.
Sorry to post to both groups but it could be relevant to both.
Regards, Murray
PS. versions of libs:
10,823 adf-facelets.jar
683,633 adf-faces-api-ea20-SNAPSHOT.jar
3,122,625 adf-faces-impl-ea20-SNAPSHOT.jar
48,742 common-annotations.jar
188,671 commons-beanutils-1.7.0.jar
46,725 commons-codec-1.3.jar
559,366 commons-collections-3.1.jar
168,446 commons-digester-1.6.jar
112,341 commons-el-1.0.jar
31,825 commons-fileupload-1.1.jar
65,621 commons-io-1.2.jar
207,723 commons-lang-2.1.jar
38,015 commons-logging-1.0.4.jar
26,089 el-api.jar
96,983 el-ri.jar
241,801 jsf-facelets1012.jar
50,491 jsp-api.jar
16,923 jstl-1.1.0.jar
252,186 myfaces-api-1.1.3-SNAPSHOT.jar
516,661 myfaces-impl-1.1.3-SNAPSHOT.jar
15,420 portlet.jar
188,993 serializer.jar
1,231,963 tomahawk-1.1.2-SNAPSHOT.jar
3,078,601 xalan.jar
1,203,860 xercesImpl.jar
194,205 xml-apis.jar
12,398,732 bytes
-----Original Message-----
From: Murray Brandon [mailto:murray@hotmagna.com]
Sent: Monday, March 27, 2006 12:08 PM
To: users@facelets.dev.java.net
Subject: Duplicate id : _id1. Child could not be added.
The following xhtml fails when I include it using ui:include.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h=" http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c=" <http://java.sun.com/jstl/core>
http://java.sun.com/jstl/core"
>
<ui:composition>
<h:outputText value="Well well well" />
<h:commandButton id="b" type="submit" action="success"
value="Submit" />
</ui:composition>
</html>
This fails, however if I change the outputText to read
<h:outputText id="a" value="Well well well" />
it works fine.
I'm including using a <c:if snippet in another file/component.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
" <http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f=" <http://java.sun.com/jsf/core>
http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets
<http://java.sun.com/jsf/facelets> "
xmlns:c="http://java.sun.com/jstl/core"
>
:
<ui:component>
:
:
<h:panelGrid id="pagePanels" width="100%">
<c:if test="#{ui.tabPanel.selection == 'user'}">
<ui:include src="file:userSearchPanel.xhtml" />
</c:if>
<c:if test="#{ ui.tabPanel.selection == 'rules'}">
<ui:include src="file:panel1.xhtml" />
</c:if>
<c:if test="#{ui.tabPanel.selection == 'role'}">
<ui:include src="file:panel2.xhtml" />
</c:if>
<c:if test="#{ui.tabPanel.selection == 'resources'}">
<ui:include src="file: controlTest.xhtml" />
</c:if>
<c:if test="#{ui.tabPanel.selection == 'system'}">
<ui:include src="file:examples2.xhtml" />
</c:if>
</h:panelGrid>
I'd rather not have to define unique ID's for each of my compositions as
I'll be re-using them a lot. Anyone got ideas what I've done wrong?
Regards, Murray