I have a selectOneRadio that updates a selectOneList, using ajax:
<h:outputLabel for="categ" value="Category" />
<h:selectOneRadio id="categ" value="#{cdManager.store.cd.categ}" required="true">
<f:selectItems value="#{cdManager.store.cd.categs}"/>
<f:ajax execute="categ" render="subcategs" listener="#{cdManager.categChanged}" />
</h:selectOneRadio>
<h:outputLabel for="subcategs" value="Sub-categ"/>
<h:selectOneListbox id="subcategs" value="#{cdManager.store.cd.subcateg}" required="true">
<f:selectItems value="#{cdManager.subcategsArray}"/>
</h:selectOneListbox>
When the page is presented, my session bean creates a new (empty) CD object. When the user fills all info and submits, the (now filled) CD object is saved, that works fine.
The problem is that the 'categ' property is being set when the user changes the radio (withou submit) and this is bad because the user can click the 'back browser' and when they come back, the radio will be selected and the other fields will empty, very bad behaviour!
How can i solve this and still use ajax?
Here is the listener code:
public void categChanged()
{
//store.cd.categ is alredy set ? WHYYY ?
String categ = store.getCd().getCateg();
this.subcategsArray = store.getCd().getSubcateg(categ);
}
I'm using JSF 2.0, NetBeans IDE 7.0.1 with Glassfish 3.1, any help would be great, thanks!