I'm creating a page to build forms and I'm using PrimeFaces component's dashboard to store and order the fields of the form. The problem is: When I try to add a new form field, by sending two input values to the Bean, the get method of dashboard is called before the set method os inputs, so I can't add the input values to dashboard.
Form.xhtml:
<h:form id="dashboardForm">
<h:panelGrid columns="4" cellpadding="5">
<p:outputLabel for="formName" value="Form Name"></p:outputLabel>
<p:inputText id="formName" placeholder="Exemple Form"></p:inputText>
</h:panelGrid>
<hr></hr>
<p:layout>
<p:layoutUnit position="west" minSize="150">
<p:panel header="Add Field">
<h:panelGrid columns="2" cellpadding="5" id="newField">
<p:outputLabel for="newFieldName" value="Question"></p:outputLabel>
<p:inputTextarea id="newFieldName" value="#{monitoringFormDashboard.newFieldName}"></p:inputTextarea>
<p:outputLabel for="newFieldType" value="Type"></p:outputLabel>
<p:selectOneMenu immediate="true" id="newFieldType" value="#{monitoringFormDashboard.newFieldType}">
<f:selectItem itemLabel="Text" itemValue="0"></f:selectItem>
<f:selectItem itemLabel="Dropdown" itemValue="1"></f:selectItem>
<f:selectItem itemLabel="Boolean" itemValue="2"></f:selectItem>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton id="addNewField" value="Add" actionListener="#{monitoringFormDashboard.addField}" update="dashboard" image="ui-icon ui-icon-carat-1-e" />
</p:panel>
</p:layoutUnit>
<p:layoutUnit position="center">
<p:dashboard id="dashboard" binding="#{monitoringFormDashboard.dashboard}">
</p:dashboard>
</p:layoutUnit>
</p:layout>
</h:form>
When I press the Add commandButton, the method execution order on bean is:
- getDashboard
- setDashboard
- getNewFieldName
- getNewFieldType
- setNewFieldName
- setNewFieldType
- addField
So this is exactly the inverse order of what I need. I need first the newFieldName and newFieldName and later call addField and at least getDashboard...
Here is the bean class if needed: http://pastebin.com/fcCnAYNZ
What is it that I'm missing?