2 Replies Latest reply on Mar 16, 2007 12:52 PM by Sergey Smirnov

    ajax4jsf blocked by <h:selectOneMenu/>

    David MacBride Newbie

      Hi,

      I getting started with a4j and implemented a basic test, and it worked. On my page I have an <h:outputText/> element whose value is successfully updated when I change the value of a specific <h:selectOneMenu/>

      So when the user modifes this <h:selectOneMenu:
      ---------------------------------------------------------
      <h:selectOneMenu styleClass="selectOneMenu"
      id="menuProductSelection"
      converter="#{productsbean.converter}"
      value="#{submitRequest.product}">
      <f:selectItems value="#{productsbean.products}"/>
      <a:support event="onchange" ajaxSingle="true" reRender="davetest1"/>
      </h:selectOneMenu>

      This outputText field is updated
      ------------------------------------
      <h:outputText id="davetest1" value="#{submitRequest.productID}"/>


      So far so good!

      However, it all breaks when I add another <h:selectOneMenu/> to the page. That is, if I simply add the following to the page:

      <h:selectOneMenu styleClass="selectOneMenu"
      id="menuCMVCRelease"
      converter="#{cmvcreleasesbean.converter}"
      value="#{submitRequest.release}">
      <f:selectItems value="#{submitRequest.productReleases}"/>
      </h:selectOneMenu>


      then my earlier success is broken. The <h:outputText id="davetest1"/> no longer changes value when <h:selectOneMenu d="menuProductSelection" /> is changed.

      It seems to be the same behaviour that I ran into when I had required="true" set on some an inputText field - I think the submission is being blocked but I don't know why.

      This seems so trivial but I'm blocked by this. How can I make this work?

      Thanks in advance!

        • 1. Re: ajax4jsf blocked by <h:selectOneMenu/>
          Sergey Smirnov Master

          "Blocks" means bypassing due validation or conversion errors. So, it is always good to have:
          <a4j:outputPanel ajaxRendered="true">
          <h:messages />
          </a4j:outputPanel>
          at least during the development time

          • 2. Re: ajax4jsf blocked by <h:selectOneMenu/>
            Sergey Smirnov Master

            Try to replace:

            <h:selectOneMenu styleClass="selectOneMenu"
            id="menuProductSelection"
            converter="#{productsbean.converter}"
            value="#{submitRequest.product}">
            <f:selectItems value="#{productsbean.products}"/>
            <a:support event="onchange" ajaxSingle="true" reRender="davetest1"/>
            </h:selectOneMenu>


            with:
            <a4j:region>
             <h:selectOneMenu styleClass="selectOneMenu"
             id="menuProductSelection"
             converter="#{productsbean.converter}"
             value="#{submitRequest.product}">
             <f:selectItems value="#{productsbean.products}"/>
             <a:support event="onchange" reRender="davetest1"/>
             </h:selectOneMenu>
            <a4j:region>


            I.e. ajaxSingle with region. It guaranties that other field of the form will be not processes

            P.S. the region without attributes is Ok for ajax4jsf 1.1.x. Otherwise, renderRegionOnly="false" is required in this particular case