New Component: Fragment

Fragment component is used to define automatic partially process and update sections whenever ajax request is triggered by a descandant component. Fragment makes it easy to define partial ajax process and update without explicitly defining component identifiers.

In the following example, required input field outside the fragment is ignored and only the contents of the fragment are processed-updated automatically on button click since button is inside the fragment.

<h:form id="form">

    <h:panelGrid columns="2">
        <p:outputLabel for="ign" value="Required:" />
        <p:inputText id="ign" required="true" />
    </h:panelGrid>

    <p:fragment autoUpdate="true">
        <h:panelGrid columns="4" cellpadding="5">
            <h:outputLabel for="name" value="Name:" />
            <p:inputText id="name" value="#{pprBean.firstname}" />
            <p:commandButton value="Submit"/>
            <h:outputText value="#{pprBean.firstname}" />
        </h:panelGrid>
    </p:fragment>

</h:form>

Check out PrimeFaces Showcase for the live demo!

This component has been requested by a PrimeFaces PRO user who has been migrating to PrimeFaces from another component suite.

This entry was posted in JSF. Bookmark the permalink.

8 thoughts on “New Component: Fragment

  1. Cool feature. I think it will be available in the next 3.5.x version.
    So I’m very curious to know what will be the exclusive features for the 4.0.