• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

DynaForm Controls

DynaForm gives access to the client ids of its controls and lets you visit all controls with a visit callback, for inter-control communication, clearing inputs and removing rows at runtime.

DynaForm Tag Documentation

DynaForm is a dynamic form component that renders based on a DynaFormModel.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
autoSubmit boolean false false When true, form is submitted automatically on change.
buttonBarPosition String false bottom Position of the button bar: 'top', 'bottom', or 'both'.
columnClasses String false Comma-separated CSS classes for label and control columns.
openExtended boolean false false When true, extended rows are shown by default.
style String false Inline style of the component.
styleClass String false Style class of the component.
value Object true The dynamic data model (e.g. DynaFormModel).
var String false Name of the request-scoped variable that exposes the current row/control data.
varContainerId String false Name of the request-scoped variable that exposes the current container client id.

DynaFormControl Tag Documentation

Defines a control template for a DynaFormControl type; used as a child of DynaForm.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
for String false Search expression for the input component this control wraps (for label 'for' and validation).
style String false Inline style of the component.
styleClass String false Style class of the component.
type String false default Control type identifier; must match a DynaFormControl type in the model.
Tag Documentation Widget Source Basic Features Controls
Utilization of container client Id

The attribute varContainerId names a variable holding the client id prefix within pe:dynaFormControl, which gives the whole client id of a component inside it. That is sometimes required for JavaScript or PrimeFaces.current().ajax().update(...). Every input here has an icon to select a value from a dialog; the value is set into the input after a click on "OK".

Access controls with visit callback and remove rows

ExecutableVisitCallback is the PrimeFaces Extensions implementation of the JSF VisitCallback. It runs any VisitTaskExecutor on all controls within pe:dynaForm, which allows inter-control communication. Here ClearInputsExecutor clears all inputs / selects of one row (see clearInputs in ClearDynaFormController). Rows are removed at runtime with removeRegularRow(...) / removeExtendedRow(...) of the DynaFormModel. Click "Clear inputs" and "Remove" to see it in action.

Usage


<style>
    .dynaform-container .pe-dynaform-cell input,
    .dynaform-container .pe-dynaform-cell[colspan="1"] input {
        width: 150px;
    }

    .dynaform-visit .pe-dynaform-cell {
        vertical-align: top;
    }

    .dynaform-visit .clearLink {
        vertical-align: middle;
    }

    .dynaform-visit .pe-dynaform-cell .p-spinner input {
        width: 60px;
    }
</style>

<div class="card dynaform-container">
    <h5>Utilization of container client Id</h5>
    <p>The attribute <code>varContainerId</code> names a variable holding the client id prefix within <code>pe:dynaFormControl</code>, which gives the whole client id of a component inside it. That is sometimes required for JavaScript or <code>PrimeFaces.current().ajax().update(...)</code>.
        Every input here has an icon to select a value from a dialog; the value is set into the input after a click on "OK".</p>
    <h:form id="formContainerClientId">
        <h:panelGroup id="dynaFormGroup">
            <p:messages id="messages" showSummary="true"/>

            <pe:dynaForm id="dynaForm" value="#{containerDynaFormController.model}"
                         var="data" varContainerId="ccId">
                <pe:dynaFormControl for="txt">
                    <h:panelGroup style="white-space: nowrap;">
                        <p:inputText id="txt" value="#{data.value}"/>
                        <p:commandButton icon="pi pi-search" process="@this txt"
                                         update=":formContainerClientId:dialogList" oncomplete="PF('dialogListWdgt').show()"
                                         title="Please choose an item"
                                         style="border:none;">
                            <f:setPropertyActionListener value="#{ccId}"
                                                         target="#{containerDynaFormController.containerClientId}"/>
                            <f:setPropertyActionListener value="#{data}"
                                                         target="#{containerDynaFormController.selectedField}"/>
                            <f:setPropertyActionListener value="#{data.value}"
                                                         target="#{containerDynaFormController.selectedItem}"/>
                        </p:commandButton>
                    </h:panelGroup>
                </pe:dynaFormControl>

                <f:facet name="buttonBar">
                    <p:commandButton value="Submit" process="dynaForm"
                                     update=":formContainerClientId:dynaFormGroup :formContainerClientId:inputValues"
                                     oncomplete="PF('inputValuesWidgetContainer').show()"/>
                </f:facet>
            </pe:dynaForm>
        </h:panelGroup>

        <p:dialog id="dialogList" widgetVar="dialogListWdgt">
            <f:facet name="header">
                Please select an item
            </f:facet>

            <h:selectOneListbox id="selectList" value="#{containerDynaFormController.selectedItem}"
                                style="width:200px;">
                <f:selectItems value="#{containerDynaFormController.list}"/>
            </h:selectOneListbox>

            <h:panelGroup layout="block" style="white-space:nowrap; margin-top:15px;">
                <p:commandButton value="OK" icon="pi pi-save" style="margin-right:5px"
                                 process="@this selectList" action="#{containerDynaFormController.updateSelection}"
                                 global="false" oncomplete="PF('dialogListWdgt').hide()"/>
                <p:commandButton value="Cancel" type="button" onclick="PF('dialogListWdgt').hide()"/>
            </h:panelGroup>
        </p:dialog>

        <p:dialog header="Input values" widgetVar="inputValuesWidgetContainer">
            <p:dataList id="inputValues" value="#{containerDynaFormController.values}" var="value"
                        style="margin:10px;">
                <h:outputText value="#{value}" style="margin-right: 15px;"/>
            </p:dataList>
        </p:dialog>
    </h:form>
</div>

<div class="card dynaform-visit">
    <h5>Access controls with visit callback and remove rows</h5>
    <p><code>ExecutableVisitCallback</code> is the PrimeFaces Extensions implementation of the JSF <code>VisitCallback</code>. It runs any <code>VisitTaskExecutor</code> on all controls within <code>pe:dynaForm</code>, which allows inter-control communication.
        Here <code>ClearInputsExecutor</code> clears all inputs / selects of one row (see <code>clearInputs</code> in <code>ClearDynaFormController</code>). Rows are removed at runtime with <code>removeRegularRow(...)</code> / <code>removeExtendedRow(...)</code> of the <code>DynaFormModel</code>.
        Click "Clear inputs" and "Remove" to see it in action.</p>
    <h:form id="formVisitCallback">
        <pe:dynaForm id="dynaForm" value="#{clearDynaFormController.model}" var="condition">
            <pe:dynaFormControl type="column">
                <p:selectOneMenu id="tableColumn" value="#{condition.tableColumn}">
                    <f:selectItem itemValue="" itemLabel=""/>
                    <f:selectItem itemValue="model" itemLabel="model"/>
                    <f:selectItem itemValue="manufacturer" itemLabel="manufacturer"/>
                    <f:selectItem itemValue="year" itemLabel="year"/>
                    <f:attribute name="rcIndex" value="#{condition.index}"/>
                </p:selectOneMenu>
            </pe:dynaFormControl>
            <pe:dynaFormControl type="offset">
                <p:spinner id="inputOffset" value="#{condition.inputOffset}" min="0" max="99">
                    <p:keyFilter mask="num"/>
                    <f:attribute name="rcIndex" value="#{condition.index}"/>
                </p:spinner>
            </pe:dynaFormControl>
            <pe:dynaFormControl type="operator">
                <p:selectOneMenu id="valueOperator" value="#{condition.valueOperator}">
                    <f:selectItem itemValue="eq" itemLabel="equal"/>
                    <f:selectItem itemValue="not" itemLabel="not equal"/>
                    <f:selectItem itemValue="gt" itemLabel="greater"/>
                    <f:selectItem itemValue="lt" itemLabel="lesser"/>
                    <f:attribute name="rcIndex" value="#{condition.index}"/>
                </p:selectOneMenu>
            </pe:dynaFormControl>
            <pe:dynaFormControl type="value">
                <p:inputText id="inputValue" value="#{condition.inputValue}">
                    <f:attribute name="rcIndex" value="#{condition.index}"/>
                </p:inputText>
            </pe:dynaFormControl>
            <pe:dynaFormControl type="clear" styleClass="clearLink">
                <p:commandLink value="Clear inputs" process="@this"
                               action="#{clearDynaFormController.clearInputs(condition.index)}"
                               global="false"/>
                <p:commandLink value="Remove" process="@this" update="dynaForm"
                               action="#{clearDynaFormController.removeCondition(condition)}"
                               global="false" style="margin-left:10px"/>
            </pe:dynaFormControl>
        </pe:dynaForm>

        <p:commandButton value="Submit form and show current values" process="dynaForm" update="conditions"
                         style="margin:15px 5px 0 0" oncomplete="PF('condValuesDlg').show()"/>
        <p:commandButton value="Show current values without submit" process="@none" update="conditions"
                         style="margin-top:15px;" oncomplete="PF('condValuesDlg').show()"/>

        <p:dialog header="Condition Values" widgetVar="condValuesDlg">
            <h:panelGroup id="conditions" layout="block" style="margin:10px;">
                <h:outputText value="#{clearDynaFormController.conditions}" escape="false"/>
            </h:panelGroup>
        </p:dialog>
    </h:form>
</div>