Ralph
Ralph

Reputation: 120771

JSF Component without own HTML element

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?

Upvotes: 1

Views: 1394

Answers (3)

user517491
user517491

Reputation:

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.

Upvotes: 3

Adam
Adam

Reputation: 5070

You can use

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

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

Upvotes: 1

Mr.J4mes
Mr.J4mes

Reputation: 9266

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>

Upvotes: 0

Related Questions