Issue with SelectOneMenu and a4j
balinju Feb 29, 2008 6:19 PMHi all,
I have an issue with a4j and SelectOneMenu item. Let me describe what I am trying to do. I have a page which guides the user to choose some options, one at a time, which is basically the following code:
<s:div id="ajaxChef"> <s:div rendered="#{askChef.step==1}"> <h:outputLabel>Are you looking for a:</h:outputLabel> <h:selectOneRadio id="restRadio" value="#{askChef.restaurantType}"> <s:selectItems id="restTypeSelectItems" value="#{eimtypeList.resultList}" var="type" label="#{type.typeName}"/> <s:convertEntity /> <a:support event="onchange" reRender="ajaxChef, searchResults" actionListener="#{askChef.find}"/> </h:selectOneRadio> </s:div> <s:div rendered="#{askChef.step==2}"> <h:outputLabel>Select Cuisine:</h:outputLabel> <h:selectOneMenu id="cuisine" value="#{askChef.cuisine}"> <s:selectItems id="cuisineSelectItems" value="#{eimcuisineList.resultList}" var="cuisine" label="#{cuisine.cuisineName}" noSelectionLabel="ANY"/> <s:convertEntity /> <a:support event="onchange" reRender="ajaxChef, searchResults" actionListener="#{askChef.find}"/> </h:selectOneMenu> </s:div> <s:div rendered="#{askChef.step==3}"> <h:outputLabel>Select Location:</h:outputLabel> <h:selectOneMenu id="town" value="#{askChef.town}"> <s:selectItems id="townSelectItems" value="#{eimtownList.resultList}" var="town" label="#{town.townName}" noSelectionLabel="ANY"/> <s:convertEntity /> <a:support event="onchange" reRender="ajaxChef, searchResults" actionListener="#{askChef.find}"/> </h:selectOneMenu> </s:div> <s:div rendered="#{askChef.step==4}"> <h:outputLabel>Select Cost Bracket:</h:outputLabel> <h:selectOneMenu id="costBracket" value="#{askChef.costBracket}"> <s:selectItems id="costBracketSelectItems" value="#{eimcostbracketList.resultList}" var="costBracket" label="#{costBracket.costValueStart} - #{costBracket.costValueEnd}" noSelectionLabel="ANY"/> <s:convertEntity /> <a:support event="onchange" reRender="ajaxChef, searchResults" actionListener="#{askChef.find}" /> </h:selectOneMenu> </s:div> <a:commandButton value="back" disabled="#{1>=askChef.step}"> <a:support event="onclick" actionListener="#{askChef.decStep}" reRender="ajaxChef, searchResults" /> </a:commandButton> <a:commandButton value="next" disabled="#{askChef.step>=4}"> <a:support event="onclick" actionListener="#{askChef.incStep}" reRender="ajaxChef, searchResults" /> </a:commandButton>
the command buttons at the bottom will increment or decrement the askChef.step value so one div tag is displayed at a time. This works perfectly well.
However, when for example the user is in step 2, and he selects his favourite cuisine, if the user first presses next, followed by the back button, the value chosen before the two keys were pressed still remains set in the bean, but the selectonemenu shows the noSelectionLabel!!
In other words, what I am trying to say is that if a user navigates to step 2 and chooses something from the selectonemenu which sets a value on a bean, if the user navigates back to that same step, the current value in the bean will not be reflected in the selectonemenu.
when I googled around, I found this post: Link Here
which shows that the selectonemenu selected item should reflect the current value of the bean's property.
thanks in advance for you help.