I am creating forms dynamically from bean. I want to bind the dynamically created components to a list of DTO's i.e a first inputtext value must be saved as a DTO object i.e List[0] , second inputtext value must be saved as a DTO object i.e List[1] , third inputtext value must be saved as a DTO object i.e List[2] .
bean
public void addInputText(String value, HtmlPanelGrid grid,
FundamentsAttributesDBDTO attribute) {
HtmlInputText inputText = new HtmlInputText();
inputText.setValue(value);
inputText.setStyleClass("tile");
inputText.setValueExpression(
"value",
createValueExpression("#{formGeneratorBean.input}",
String.class));
grid.getChildren().add(inputText);
}
public static ValueExpression createValueExpression(String valueExpression,
Class<?> valueType) {
FacesContext context = FacesContext.getCurrentInstance();
return context
.getApplication()
.getExpressionFactory()
.createValueExpression(context.getELContext(), valueExpression,
valueType);
}
xhtml
<h:body>
<h:form id="form" binding="#{formGeneratorBean.form}" />
</h:body>
the values in the created form must be filled in this list
private transient List<ValuesDTO> valuesList = new ArrayList<ValuesDTO>();
Please Help me with this issue.