sections.dynaform.visitCallback.xhtml Maven / Gradle / Ivy
The newest version!
This example demonstrates how to use ExecutableVisitCallback - PrimeFaces Extensions'
implementation of the JSF API's interface VisitCallback.
ExecutableVisitCallback uses any class which implements the interface VisitTaskExecutor
(this interface is defined in the PrimeFaces Extensions). This approach allows to visit
all controls within pe:dynaForm and to execute any task on them. By this way,
we can implement inter-control (inter-cell) communication within pe:dynaForm.
In this example, we will implement the interface VisitTaskExecutor by the class
ClearInputsExecutor which clears all inputs / selects related to one row in pe:dynaForm.
The ClearInputsExecutor is instantiated and and set into the ExecutableVisitCallback.
That happens in the ClearDynaFormController (see the action method clearInputs).
This example also demonstrates how to remove rows at runtime. Rows can be removed by the following methods in the
DynaFormModel:
- removeRegularRow(DynaFormRow row)
- removeRegularRow(int index)
- removeExtendedRow(DynaFormRow row)
- removeExtendedRow(int index)
You see here an imaginary filter mask with three rows and four input / select components in each row.
Click on "Clear inputs" and "Remove" links to see this example in action!
${showcase:getFileContent('/sections/dynaform/example-visitCallback.xhtml')}
${showcase:getFileContent('/org/primefaces/extensions/showcase/controller/dynaform/ClearDynaFormController.java')}
${showcase:getFileContent('/org/primefaces/extensions/showcase/model/dynaform/Condition.java')}
${showcase:getFileContent('/org/primefaces/extensions/showcase/controller/dynaform/ClearInputsExecutor.java')}