Theme
arya
luna-amber
luna-blue
luna-green
luna-pink
nova-dark
nova-light
saga
vela
DynaForm
This example demonstrates how to use nested model. You can picture it as a table contained in a cell. This is very useful when your control is a combination of pe:dynaFormControl. Note, XHTML code with pe:dynaForm stays the same, only Java model gets changed. Main steps:

  • Create parent model instance: DynaFormModel model = new DynaFormModel();
  • Add row, label, control and set relationship as you would do in normal case,
  • Create nested model instance: DynaFormModel nestedModel = new DynaFormModel();
  • Add row to regular grid: DynaFormRow nestedRow = nestedModel.createRegularRow();
  • Add label, control and set relationship as usual,
  • Add nested model: nestedRow.addModel(data, type, colspan, rowspan);
Search area
Source

<h:panelGroup id="dynaFormGroup">
    <p:messages id="messages" showSummary="true"/>  
    
    <pe:dynaForm id="dynaForm" value="#{nestedDynaFormController.model}" var="data" >
        <pe:dynaFormControl type="input" for="txt">
            <p:inputText id="txt" value="#{data.value}" required="#{data.required}"/>
        </pe:dynaFormControl>
        
        <pe:dynaFormControl type="date" for="cal" styleClass="calendar">
            <p:calendar id="cal" value="#{data.value}" required="#{data.required}" showOn="button"/>
        </pe:dynaFormControl>

        <f:facet name="headerRegular">  
           <div><h:outputText value="Search area" /></div>
        </f:facet>
        
        <f:facet name="buttonBar">
            <p:commandButton value="Submit" action="#{nestedDynaFormController.submitForm}"
                             process="dynaForm" update=":mainForm:dynaFormGroup :mainForm:inputValues"
                             oncomplete="handleComplete(xhr, status, args)"/>
            <p:commandButton type="reset" value="Reset" style="margin-left: 5px;"/>
        </f:facet>
    </pe:dynaForm>
</h:panelGroup>

<p:dialog header="Input values" widgetVar="inputValuesWidget">
    <p:dataList id="inputValues" value="#{nestedDynaFormController.bookProperties}" var="bookProperty"
                style="margin:10px;">
        <h:outputText value="#{bookProperty.name}: #{bookProperty.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">
    .pe-dynaform-cell .ui-calendar input {  
        width: 100px;  
    }
    .pe-dynaform-headerfacet div{  
        border: 1px dotted #808080;  
        padding: 10px;  
        text-align: center;  
    }    
    .pe-dynaform-label {  
        text-align: left;  
        padding: 2px 20px 0 0;  
    }
</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: 13.0.0,PrimeFaces Extensions: 13.0.1,JSF: Apache MyFaces JSF-2.3 Core Impl 2.3.10,Server: jetty/9.4.36.v20210114,Build time: 2023-09-11 19:07