I really need your help please. First of all, I want to let you know that I am a beginner in JSF.
I've got a form with several parameters. The flowtype field has 2 options : Sync and async. At the first launch, I am able to get the source value but When it pass to async I am doing a query to database so as to populate the source, datatype... by using ajax and it's working very well but I am not anymore able to retrieve the value of selectOneMenu. I got an error validation...
this is my form :
<h:form id="monitoring_form">
<p:growl id="msgs" showDetail="true" />
<p:panel header="Select a Location" style="margin-bottom:10px;">
<p:outputLabel id="flowType_label" value="Flow Type : "/>
<h:selectOneMenu id="flowType_select" value="#{monitoringBean.flowType}">
<p:ajax listener="#{monitoringBean.onFlowTypeChange}" process="@this" update="source_select,:monitoring_form:dataType_select" />
<f:selectItem itemLabel="Select a flow type" itemValue="" noSelectionOption="true" />
<f:selectItem itemValue="async" itemLabel="ASYNC" />
<f:selectItem itemValue="sync" itemLabel="SYNC" />
</h:selectOneMenu>
<p:outputLabel id="source_label" value="Source"/>
<h:selectOneMenu id="source_select" value="#{monitoringBean.source}">
<f:selectItem itemLabel="ALL" itemValue=""/>
<f:selectItems value="#{monitoringBean.resultSource}"/>
</h:selectOneMenu><br/>
<p:outputLabel id="dataType_label" value="Datatype : "/>
<h:selectOneMenu id="dataType_select" value="#{monitoringBean.dataType}">
<f:selectItem itemLabel="ALL" itemValue="" noSelectionOption="true"/>
<f:selectItems value="#{monitoringBean.resultDataType}"/>
</h:selectOneMenu>
<p:commandButton ajax="false" id="submit" actionListener="#{monitoringBean.buttonAction}" value="Submit" type="submit" icon="ui-icon-check" />
<p:commandButton value="Reset" type="reset" icon="ui-icon-close"/>
</p:panel>
</h:form>
this is my onFlowChangeValue :
public void onFlowTypeChange(AjaxBehaviorEvent event) throws SQLException {
if (flowType != null && !flowType.equals("") && !flowType.equals("sync")) {
addMessage("Welcome to Primefaces!!" + " source : " + source);
selectSourceApplicationFromTable(); // -> add to resultSource list of selectItem..
selectDataTypeFromTable(); // ->add to resultDataType list of selectItem..
}
}
I check the flowTypeValue and I do a request to my database so as to populate the selectOneMenu.
This is my button submit action method :
public void buttonAction(ActionEvent actionEvent) {
addMessage("Welcome to Primefaces!!" + " source : " + source);
System.out.println("Source : " + source);
}
Firstly without using the form just pressing Submit I got : ""Welcome to Primefaces!!" + " source : " + null" fine. But when i change the flowtype value I got an error when submitting.
How can I get the selectOneMenu value ? Why it's not accessible by using my bean #{monitoringBean.source} ?
PS: I used this tutorial : http://www.primefaces.org/showcase/ui/ajax/dropdown.xhtml
Thanks.