suggestionbox + combobox
roanbrasil Aug 12, 2009 3:43 PMHello everybody, I have one question here.
I am making a suggestionbox (city) and 2 combobox (State and Country). Well, when i'm typing for example - TarryTown my suggestion box will show, TarryTown, NewYork, USA . If I submit this form and don't fill out the another required fields will show the message value is required and then when I go to change city to Pune in INDIA, will be necessary reRender the field state and country. But before I submit works fine, after I submitted it's not working because the state is reRendered but don't put as selected my state. Can someone help me please?
<h:form id="addUserForm" styleClass="edit"> <rich:panel> <f:facet name="header">User Registration:</f:facet> <h:panelGrid > <s:decorate id="usernameDecoration" template="../layout/edit.xhtml"> <ui:define name="label">Username :</ui:define> <h:inputText value="#{userBean.user.username}" id="username" label="username" required="true" size="15" maxlength="20" /> </s:decorate> <s:decorate id="passwordDecoration" template="../layout/edit.xhtml"> <ui:define name="label">Password :</ui:define> <h:inputSecret value="#{userBean.user.password}" id="password" label="password" required="true" size="15" maxlength="20" /> </s:decorate> <s:decorate id="retypePasswordDecoration" template="../layout/edit.xhtml"> <ui:define name="label">Retype Password :</ui:define> <h:inputSecret value="#{userBean.verifyPassword}" id="verify" label="verify" required="true" size="15" maxlength="20" /> </s:decorate> <s:decorate id="townDecoration" template="../layout/edit.xhtml"> <ui:define name="label">City :</ui:define> <h:inputText value="#{userBean.town.name}" id="town" label="town" required="true" size="25" maxlength="200" var="townName" rendered="true" > <a4j:support event="onchange" reRender="country,printState" immediate="true" /> </h:inputText> <rich:suggestionbox id="suggestion" for="town" suggestionAction="#{userBean.suggestionTown}" width="200" height="100" var="result" minChars="3" fetchValue="#{result.name}" reRender="printStateId,printState,state,printCountryId,printCountry,country" immediate="true" > <h:column> <h:outputText value="#{result.name},#{result.state.name},#{result.country.name}" id="output" rendered="true"> </h:outputText> </h:column> <a4j:support event="onselect" action="#{userBean.actionLoadStatesBySuggestionBox}" reRender="printStateId,country,state,printCountry,printCountryId, printState" ajaxSingle="true" > <f:setPropertyActionListener value="#{result}" target="#{userBean.town}" /> <f:setPropertyActionListener value="#{result.state}" target="#{userBean.state}" /> <f:setPropertyActionListener value="#{result.country.id}" target="#{userBean.country.id}" /> </a4j:support> </rich:suggestionbox> </s:decorate> <s:decorate id="stateDecoration" template="../layout/edit.xhtml"> <ui:define name="label">State :</ui:define> <h:selectOneMenu value="#{userBean.state}" id="state" required="true" rendered="true" converter="#{conversor}" > <f:selectItems value="#{userBean.states}" /> </h:selectOneMenu> </s:decorate> <s:decorate id="printStateDecoration" template="../layout/edit.xhtml"> <ui:define name="label">Print State :</ui:define> <h:outputText value="#{userBean.state.name}" id="printState" rendered="true"/> <h:outputText value="#{userBean.state.id}" id="printStateId" rendered="true"/> </s:decorate> <s:decorate id="countryDecoration" template="../layout/edit.xhtml"> <ui:define name="label">Country :</ui:define> <h:selectOneMenu value="#{userBean.country.id}" id="country" required="true" rendered="true" immediate="true" > <f:selectItems value="#{userBean.allCountries}" /> </h:selectOneMenu> </s:decorate> <s:decorate id="printCountryDecoration" template="../layout/edit.xhtml"> <ui:define name="label">Print Country :</ui:define> <h:outputText value="#{userBean.country.name}" id="printCountry" rendered="true"/> <h:outputText value="#{userBean.country.id}" id="printCountryId" rendered="true"/> </s:decorate> <s:decorate id="zipCodeDecoration" template="../layout/edit.xhtml"> <ui:define name="label">Zip Code :</ui:define> <h:inputText value="#{userBean.address.zipcode}" id="zipcode" label="zipcode" required="true" size="15" maxlength="25" /> </s:decorate> <s:decorate id="buttonDecoration" template="../layout/edit.xhtml"> <h:commandButton action="#{userBean.save()}" value="Register" /> <a4j:commandButton action="#{userBean.save()}" value="Register A4J" /> </s:decorate> </h:panelGrid> </rich:panel> </h:form>