sections.dynaform.basicUsage.xhtml Maven / Gradle / Ivy
This example demonstrates how to build a simple dynamic form. Main steps:
- Create model instance: DynaFormModel model = new DynaFormModel();
- Add row to regular grid: DynaFormRow row = model.createRegularRow();
- Add label: DynaFormLabel label = row.addLabel(value, colspan, rowspan);
- Add editable control: DynaFormControl control = row.addControl(data, type, colspan, rowspan);
- Set relationship between label and control (optional): label.setForControl(control);
Repeat four last steps as many times as needed.
The main component tag is pe:dynaForm. Child tag pe:dynaFormControl matches created
in Java controls by type attribute. This is usually a "one to many" relation.
You also see that one of important features is a buil-in support for labels. DynaForm renders labels automatically -
no need to write p:outputLabel. But of course h:outputText can be used as a quite
normal tag inside pe:dynaFormControl with a proper type as well.
${showcase:getFileContent('/sections/dynaform/example-basicUsage.xhtml')}
${showcase:getFileContent('/org/primefaces/extensions/showcase/controller/dynaform/DynaFormController.java')}
${showcase:getFileContent('/org/primefaces/extensions/showcase/model/dynaform/BookProperty.java')}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy