s:decorate: problem with correct rerendering
rdeckbuzzamite Apr 15, 2011 1:54 AMThe task which I have to do is the following:
On a form where you can enter zip/city (one field) and choose country (another field), there shall be a suggestionBox for the zip/city field, but only when the country is switzerland, because for this country I have data available through a suggestion service.
So I use a a4j:support on the country selection field where I rerender the s:decorate field containing the zip/city field.
The effect is that the rendering condition of the suggestionbox (s:fragment) will be evaluated (correct), but the zip/city field will also be rerender, which I don't want. So I tried to rerender only the s:fragment part, but then, the condition is not evaluated correctly.
How can I do it to not rerender the zip/city field and get the rendering condition of the suggestionBox still correct?
Below is my code:
<a4j:outputPanel id="locationPlzNameCountry" layout="block"> <s:decorate id="locationPlzName" template="/layout/forms_edits.xhtml"> <ui:define name="label">#{messages['myaccount.personal.codePlace']}</ui:define> <ui:define name="control"> <h:inputText id="zipCity" value="#{personalBean.zipCity}" required="false" /> <s:fragment id="locationPlzNameSuggest" rendered="#{personalBean.curriculumVitae.userAccount.address.country.key == 'switzerland' || personalBean.curriculumVitae.userAccount.address.country.key == 'liechtenstein'}"> <rich:suggestionbox id="zipCitySuggestionBox" height="300" width="227" var="_suggest" suggestionAction="#{locationSuggestionBean.suggestZipCity}" nothingLabel="#{messages['jobsearch.search.city.noresult']}" for="zipCity" minChars="2" limitToList="true"> <h:column> <h:outputText value="#{_suggest}" /> </h:column> </rich:suggestionbox> </s:fragment> </ui:define> </s:decorate> <s:decorate template="/layout/forms_edits.xhtml"> <ui:define name="label">#{messages['myaccount.personal.land']}<b class="grey">*</b> </ui:define> <ui:define name="control"> <h:selectOneMenu required="true" requiredMessage="#{messages['myaccount.curriculum.personal.country.required']}" value="#{personalBean.curriculumVitae.userAccount.address.country}"> <s:selectItems value="#{myAccountBean.countryList}" var="country" label="#{countryConverter.label(country)}" noSelectionLabel="#{messages['myaccount.curriculum.no_selection']}" /> <f:converter converterId="countryConverter" /> <a4j:support event="onchange" reRender="locationPlzNameCountry" limitToList="true" ajaxSingle="true" /> </h:selectOneMenu> </ui:define> </s:decorate> </a4j:outputPanel>
Here the forms_edit.xhtml template:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib"> <div class="formEntry"> <s:label id="inputLabel"> <ui:insert name="label" /> </s:label> <s:span styleClass="#{invalid ? 'errors' : ''}" id="input"> <s:validateAll> <ui:insert name="control"/> </s:validateAll> </s:span> <s:span rendered="#{invalid}" styleClass="errors" id="inputError"> <br/> <s:message styleClass="errorMessage"/> </s:span> </div> </ui:composition>
Any help will be greatly appreciated!