I would like to add PrimeFaces components like inputText
, calendar
etc dynamically from bean. I have tried in several possible ways, but I couldn't add PrimeFaces components dynamically from bean.
View:
<pe:dynaForm id="dynaForm" value="#{formGeneratorBean.model}" var="data">
<pe:dynaFormControl type="input" for="txt">
<p:inputText id="txt" value="#{data.value}" required="#{data.required}" />
In place of p:inputText
</pe:dynaFormControl>
</pe:dynaForm>
Model:
public FormGeneratorBean() {
model = new DynaFormModel();
DynaFormRow row = model.createRegularRow();
DynaFormLabel label11 = row.addLabel("Author", 1, 1);
DynaFormControl control12 = row.addControl(new BookProperty("Author",
true), "input", 1, 1);
label11.setForControl(control12);
}