我想从bean动态添加inputText
,calendar
等PrimeFaces组件。我已尝试过几种可能的方法,但我无法从bean动态添加PrimeFaces组件。
查看:
<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>
型号:
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);
}
答案 0 :(得分:0)
将类型日历添加到您的视图
<pe:dynaFormControl type="calendar" for="cal" styleClass="calendar">
<p:calendar id="cal" value="#{data.value}" showOn="button"/>
</pe:dynaFormControl>
&#13;
您的addControl方法应设置类型日历,例如:
DynaFormControl control12 = row.addControl(new Field("Birth Date",
true), "calendar", 1, 1);
您可以为所需的所有类型添加pe:dynaFormControls,只有在添加与其相关的控件时才会显示它们。