2 Replies Latest reply on Jan 18, 2008 10:46 AM by jneubert

    ui example: How to add ajax support for selectItems

    jneubert Newbie

      I have a use case very similar to the continent/country fields in the ui example, and try to add ajax: The selectItems list for countries should be updated and rerendered when the user selects a continent.

      I tried the straightforward approach:

      <s:decorate template="decorateField.xhtml">
       <ui:define name="label">Continent of Birth</ui:define>
       <h:selectOneMenu value="#{personHome.instance.continent}" required="true" id="continent">
       <s:selectItems value="#{continents.resultList}" var="continent" label="#{continent.name}" noSelectionLabel="Please Select..."/>
       <s:convertEntity />
       <a:support event="onchange" reRender="countrySelect" />
       </h:selectOneMenu>
      </s:decorate>
      
      <s:decorate template="decorateField.xhtml">
       <ui:define name="label">Country of Birth</ui:define>
       <h:selectOneRadio id="countrySelect" value="#{personHome.instance.country}" required="true" disabled="#{empty person.continent}">
       <s:selectItems value="#{personHome.instance.continent.countries}" var="country" label="#{country.name} (#{country.continent.name})" noSelectionLabel="Please Select..." hideNoSelectionLabel="true"/>
       <s:convertEntity />
       </h:selectOneRadio>
      </s:decorate>
      

      (and a lot more), but nothing worked, the country selection is not rerendered. Can anybody help, please?