1

I am looking for a JSF 2.0 Component that is just an container for other components but do not produce own HTML elements.

My situation is that I have an (already styled) jsf-xhtml component page. Now I need to disable a lot of the rendering.

<ui:component>
    <h:panelGroup layout="block" rendered="#{not empty user.registrations}">...</>
    <h:panelGroup layout="block" rendered="#{not empty user.registrations}">...</>
    <h:panelGroup layout="block" rendered="#{not empty user.registrations}">...</>
    <h:panelGroup layout="block" rendered="#{not empty user.registrations}">...</>
</ui:component>

But I do not want to specify the rendered="#{not empty user.registrations}" fore times. Instead I want to wrapp it with some component like:

<ui:component>
    <xxxx  rendered="#{not empty user.registrations}">
        <h:panelGroup layout="block">...</>
        <h:panelGroup layout="block">...</>
        <h:panelGroup layout="block">...</>
        <h:panelGroup layout="block">...</>
    </xxxx>
</ui:component>

Because the page is already styled (and I fear that this is done in a fragile way) I need an jsf-component (xxxx) that does NOT produce own html elements like div or so. Does such an jsf-component exit?

Ralph
  • 118,862
  • 56
  • 287
  • 383

3 Answers3

3

If you are using primefaces then you have a simple solution:

use p:outputPanel.

If not, then you can also use h:panelGroup. This does not have any formatting of its own.

1

You can use

<ui:fragment rendered="#{not empty user.registrations}">

http://javaserverfaces.java.net/nonav/docs/2.1/vdldocs/facelets/ui/fragment.html

Adam
  • 5,045
  • 1
  • 25
  • 31
  • This was the element I was looking for, anywaz this Question http://stackoverflow.com/q/3713468/280244 prevents me from using `ui:fragment` – Ralph Jul 10 '12 at 16:55
0

Try this:

<c:if test="#{not empty user.registrations}">
    <h:panelGroup layout="block">...</>
    <h:panelGroup layout="block">...</>
    <h:panelGroup layout="block">...</>
    <h:panelGroup layout="block">...</>
</c:if>

or you can wrap your 4 <h:panelGroup> with another <h:panelGroup>:

<h:panelGroup rendered="#{not empty user.registrations}">
    <h:panelGroup layout="block">...</>
    <h:panelGroup layout="block">...</>
    <h:panelGroup layout="block">...</>
    <h:panelGroup layout="block">...</>
</h:panelGroup>
Mr.J4mes
  • 9,168
  • 9
  • 48
  • 90