webtier@glassfish.java.net

confusing ui:fragment rendered attribute

From: <webtier_at_javadesktop.org>
Date: Tue, 09 Feb 2010 13:57:48 PST

Hi!

I tried to encapsulate standard tags like button, textBox and so on into a composite component to control the whole application behavior at a single point.
I grouped the button tags (button, commandButton) into one composite component and separated both tags with a [b]fragment[/b] tag like this:

<ui:fragment rendered="#{cc.attrs.isCommandButton}">
  <h:commandButton id="#{cc.attrs.id}" styleClass="button"/>
</ui:fragment>
<ui:fragment rendered="#{not cc.attrs.isCommandButton}">
    <h:button id="#{cc.attrs.id}" styleClass="button"/>
</ui:fragment>

Further attributes will be added with <f:attribute/> tag.

Now I will get an error caused by "Not unique ID". And the component tree looks like this:

<ComponentRef id="j_idt55" inView="true" rendered="true" transient="false">
    <HtmlCommandButton disabled="false" id="brand-item" immediate="false" inView="true" readonly="false" rendered="true" style="float:right; width: 100px;" styleClass="button" transient="false" type="submit" binding="#{cc.attrs.binding}">
    </HtmlCommandButton>
</ComponentRef>
<ComponentRef id="j_idt58" inView="true" rendered="false" transient="false">
    <HtmlOutcomeTargetButton id="brand-item" inView="true" includeViewParams="false" rendered="true" style="float:right; width: 100px;" styleClass="button" transient="false" binding="#{cc.attrs.binding}">
    </HtmlOutcomeTargetButton>
</ComponentRef>

The simple <h:button> shouldn't be rendered, 'cause the [b]rendered[/b] attribute is set to [b]false[/b] .

Is it possible to [b]ignore[/b] the part in the fragment-tag with rendered attribute [b]false[/b] in the component tree?

thanks for the help in advance.
[Message sent by forum member 'bitschleuder' (florian.schebelle_at_arcor.de)]

http://forums.java.net/jive/thread.jspa?messageID=385762