Reputation: 1193
What I am trying to accomplish is being able to take a section of code / HTML and tell JSF to include it or not in the final render. I have messed around with the <ui:remove>
tag, but that will always remove the contents.
Here is what I am trying to not include:
<li><h:commandLink value="Create an Account" action="createUser"/></li>
<li><h:commandLink value="Login" action="login"/></li>
I need something to wrap around this that will include it on a rendered = true/false basis. I want it to not include any bloated code like a div, table, etc.
Upvotes: 2
Views: 54
Reputation: 6138
Hope I understand your question right, have you tried these components with rendered attribute?
Example:
<h:panelGroup rendered="#{bean.display}">
<li><h:commandLink value="Create an Account" action="createUser"/></li>
<li><h:commandLink value="Login" action="login"/></li>
</h:panelGroup>
<h:panelGrid rendered="#{bean.display}">
<li><h:commandLink value="Create an Account" action="createUser"/></li>
<li><h:commandLink value="Login" action="login"/></li>
</h:panelGrid>
<rich:panel rendered="#{bean.display}">
<li><h:commandLink value="Create an Account" action="createUser"/></li>
<li><h:commandLink value="Login" action="login"/></li>
</rich:panel>
'display' is the boolean property defined in your JavaBean which you use to control the visibility of your XHTML code.
Another tag you can use is <ui:include>
, it might help you better organize your code when the section of XHTML code is big enough to put in another .xhtml.
<ui:include src="yourPath.xhtml" rendered="#{bean.display}">
</ui:include>
For <ui:remove>
, I usually use it to temporarily comment out the code as <!-- XHTML code -->
.
Upvotes: 2