Theme
arya
luna-amber
luna-blue
luna-green
luna-pink
nova-dark
nova-light
saga
vela
DynaForm
This example demonstrates how to build an advanced dynamic form with facets, autoSubmit feature and extended view area (grid).

When you see this page, the form was already submitted on page load automatically - autoSubmit feature allows to submit the form after the current page has been loaded. What it is good for? autoSubmit flag makes possible to pass form parameters in URL, build a form on page load and submit it automatically. Extended grid with form elements is closed per default, but you can open it by using of client-side API (see last form button). Open / close state is managed automatically, so that the form is shown correct after a postback update.
This is a regular header area
This is a regular footer area
Source

<h:panelGroup id="dynaFormGroup">
    <p:messages id="messages" showSummary="true"/>

    <pe:dynaForm id="dynaForm" value="#{advancedDynaFormController.model}" var="data"
                 autoSubmit="true" buttonBarPosition="both" widgetVar="dynaFormWidget">
        <pe:dynaFormControl styleClass="pe-dynaform-label">
            <h:outputText value="#{data}"/>
        </pe:dynaFormControl>
        <pe:dynaFormControl type="input" for="input">
            <p:inputText id="input" value="#{data.value}" required="#{data.required}"/>
        </pe:dynaFormControl>
        <pe:dynaFormControl type="date" for="date" styleClass="calendar">
            <p:calendar id="date" value="#{data.value}" required="#{data.required}" showOn="button"/>
        </pe:dynaFormControl>
        <pe:dynaFormControl type="desc" for="desc">
            <p:inputTextarea id="desc" value="#{data.value}" required="#{data.required}" autoResize="false"/>
        </pe:dynaFormControl>

        <f:facet name="headerRegular">
            <div><h:outputText value="This is a regular header area"/></div>
        </f:facet>
        <f:facet name="footerRegular">
            <div><h:outputText value="This is a regular footer area"/></div>
        </f:facet>
        <f:facet name="headerExtended">
            <div><h:outputText value="This is an extended header area"/></div>
        </f:facet>
        <f:facet name="footerExtended">
            <div><h:outputText value="This is an extended footer area"/></div>
        </f:facet>        
        <f:facet name="buttonBar">
            <p:commandButton value="Search" action="#{advancedDynaFormController.submitForm}"
                             process="dynaForm" update=":mainForm:dynaFormGroup :mainForm:inputValues"
                             oncomplete="handleComplete(xhr, status, args)"/>
            <p:commandButton type="reset" value="Reset" style="margin-left: 5px;"/>
            <p:commandButton type="button" value="Show / hide advanced search" style="margin-left: 5px;"
                             onclick="PF('dynaFormWidget').toggleExtended()"/>
        </f:facet>
    </pe:dynaForm>
</h:panelGroup>

<p:dialog header="Input values" widgetVar="inputValuesWidget">
    <h:outputText value="Search has been executed with values:"/>
    <p:dataList id="inputValues" value="#{advancedDynaFormController.inventoryProperties}" var="property"
                style="margin:10px;">
        <h:outputText value="#{property.position}: #{property.formattedValue}"
                      style="margin-right: 10px;"/>
    </p:dataList>
</p:dialog>

<h:outputScript id="dynaFormScript" target="body">
/* <![CDATA[ */
    function handleComplete(xhr, status, args) {
        if(args && args.isValid) {
            PF('inputValuesWidget').show();
        } else {
            PF('inputValuesWidget').hide();
        }
    }
/* ]]> */
</h:outputScript>

<h:outputStylesheet id="dynaFormCSS">
    /* note: trick with colspan is needed for IE8 */
    .pe-dynaform-cell input,
    .pe-dynaform-cell textarea,
    .pe-dynaform-cell[colspan="1"] input,
    .pe-dynaform-cell[colspan="1"] textarea {
        width: 130px;
    }

    /* note: trick with colspan is needed for IE8 */
    .pe-dynaform-cell.calendar input,
    .pe-dynaform-cell[colspan="1"].calendar input {
        width: 100px;
    }
    
    .pe-dynaform-headerfacet div,
    .pe-dynaform-footerfacet div {
        border: 1px dotted #808080;
        padding: 10px;
        text-align: center;
    }    
</h:outputStylesheet>
            
Components and more
Documentation
Attributes (move mouse over the names to see data types)
Name Description
id Unique identifier of the component in a naming container.
rendered Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar Name of the client side widget.
value Instance of type DynaFormModel representing model of this component.
var Name of the request-scoped variable for the underlaying object for each iteration.
varContainerId Name of the request-scoped variable which contains the prefix of the client ID within pe:dynaFormControl. This property allows to get the whole clientId of a component within pe:dynaFormControl. The whole client ID is sometimes required for JavaScript or RequestContext.update(...).
autoSubmit Flag whether the form has to be submitted automatically after current page has been loaded. Note: the form can be submitted if it contains at least one submit button. Default value is false.
openExtended Flag whether the extended grid has to be shown opened on page load. Default value is false.
buttonBarPosition Button bar position. Possible values are "top" | "bottom" | "both". Default value is "bottom".
style Style of the main container element. Default value is null.
styleClass Style class of the main container element. Default value is null.
columnClasses Comma separated list of label and control style classes. Default value is null.
PrimeFaces Extensions Showcase - © 2011-2023,PrimeFaces: 14.0.5,PrimeFaces Extensions: 14.0.5,JSF: Apache MyFaces JSF-2.3 Core Impl 2.3.10,Server: jetty/9.4.36.v20210114,Build time: 2024-09-10 21:01