3 Replies Latest reply on Mar 26, 2007 3:02 PM by Sergey Smirnov

    selectOneMenu looses data in ajax region

    chelaru.viorel Newbie

      hi all,
      i have a really big problem; i use myfaces 1.1.4 and tomahawk 1.1.3 and ajaxjsf 1.1.0;

      i've made an a4j region that contains besides other components, 3 selectOneMenu-s ; 1 is societa, 2 is fondo, 3 is divisa; if i select a societa, the fondo selectOneMenu is reloading, if i select a fondo the divisa selectOneMenu is reloading... all with ajax;

      when i enter the page, the societa selectOneMenu is loaded, and fondo and divisa selectOneMenu-s are empty...because all combos depend on each others selection.

      the problem is that after i select a societa, and then a fondo and then i press the button(t:commandButton) to submit the page... i get a validation error near the fondo selectOneMenu...that says "Value is not an option"; i went to the html generated and i saw that the fondo is empty; and of course .. in the bean , the selectedFondoSO property was set....and now wants to select some fondo from a list of nothing; if i press the second time the submit button ...it WORKS...again i when to the generated html and the fondo selectOneMenu EXISTS...it's not empty....why the second time works ? i think it has something to do with the lifecycle phases of ajax4jsf.

      please help...it's a bit urgent... thanks...

      here is a bit of the code extracted from my page...:

      <a4j:region selfRendered="true" id="insOrdAjaxRegionId" >
      <h:form id="insOrdFormId">
       <t:saveState value="#{bcoSession}" />
       <t:saveState value="#{insertOrdersBean}" />
      ..........................
      <t:selectOneMenu id="societa_id" forceId="true" styleClass="standardComboClass"
       binding="#{insertOrdersBean.societaSelectOneMenu}"
       value="#{insertOrdersBean.selectedSocieta}"
       >
       <a4j:support event="onchange" id="ajaxRefreshFondiId"
       action="#{insertOrdersBean.reloadFondiList}"
       reRender="fondiSO_id,fondiRI_id"
       immediate="true"
       onsubmit="antiDummyInsOrd(true);"
       oncomplete="antiDummyInsOrd(false);showHideDisableEnable();"
       />
       <f:selectItems value="#{insertOrdersBean.societaList}" />
       </t:selectOneMenu>
       <t:message for="societa_id" styleClass="error" showDetail="true"
       showSummary="false" />
      ...........................
      
      <t:selectOneMenu id="fondiSO_id" forceId="true" styleClass="standardComboClass"
       value="#{insertOrdersBean.selectedFondoSO}"
       binding="#{insertOrdersBean.fondiSOSelectOneMenu}"
       >
       <a4j:support event="onchange" id="ajaxRefreshDivisaId_SO"
       action="#{insertOrdersBean.reloadDivisaList}"
       reRender="divisa_id"
       immediate="true"
       onsubmit="if ( operSORIChecked() ) antiDummyInsOrd(true); else return false; "
       oncomplete="antiDummyInsOrd(false);showHideDisableEnable();"
       />
       <f:selectItems value="#{insertOrdersBean.fondiList}" />
       </t:selectOneMenu>
       <t:message for="fondiSO_id" styleClass="error" showDetail="true"
       showSummary="false" />
      ...................................
      <t:selectOneMenu id="divisa_id" forceId="true" styleClass="standardComboClass"
       value="#{insertOrdersBean.selectedDivisa}"
       binding="#{insertOrdersBean.divisaSelectOneMenu}">
       <f:selectItems value="#{insertOrdersBean.divisaList}" />
       </t:selectOneMenu>
       <t:message for="divisa_id" styleClass="error" showDetail="true"
       showSummary="false" />
      ....................
       </h:form>
      </a4j:region>
      


        • 1. Re: selectOneMenu looses data in ajax region
          Sergey Smirnov Master

          I doubt about two things:
          1. why you use a4j:region selfRendered="true"
          2. why you have immediate="true" for a4j:support

          Also, your h:message components are not ajax enabled.
          Use outputPanel there, like:

          <a4j:outputPanel ajaxRendered="true">
          <t:message for="societa_id" styleClass="error" showDetail="true" showSummary="false" />
          </a4j:outputPanel>


          • 2. Re: selectOneMenu looses data in ajax region
            chelaru.viorel Newbie

            hi,
            first thanks for replying...

            -i used a4j:region selfRendered="true" because i saw the demo from jboss called dropDrowBoxes which is done with a4j:region

            -i used immediate=true for a4j:support because in my form i have other inputs like...dates...that can rise validations errors....

            -i ajax-enabled my t:message components...

            the problem is that when i use a4j:outputPanel instead of a4j:region the page is displayed (of course... if i go to View Source .... the reloaded combo values are there...which is very fine...), but only the outputPanel subtree is rerendered.....and the other things not.... i use tiles... i have a menu on left and e header on top of the page... and css .... nothing is rendered....the outputPanel has no css....what can i do to preserve the outputPanel functionality but to have the hole page.....

            thanks,
            Viorel

            • 3. Re: selectOneMenu looses data in ajax region
              Sergey Smirnov Master

              Viorel, you need to learn a basic concepts of Ajax4jsf, I think. I see that your expectations do not match how the stuff should work. selfRendered="true" means rendering directly from the component tree with our re-rendering the page stuff. immediate=true allows to perform the validation process for this component earlier, but it does not to prevent bypassing the INVOKE APPLICATION phase where action methods are invoked. a4j:outputPanel has nothing common with a4j:region, so, it might not be replaced with each other.