7 Replies Latest reply on Feb 15, 2010 6:07 AM by Alex Cougarman

    a4j:support controls interfere with each other

    Alex Cougarman Apprentice
      I'm having a problem where two a4j:support controls seem to be interfering with each other. When the value in an h:selectOneRadio with an a4j:support changes, it wipes out the values in an unrelated a4j:outputPanel's controls. Here's the code for the selectOneRadio control and its associated outputPanel:

       

      <h:selectOneRadio value="#{webencode.requestType}"
        id="rdoRequestType" styleClass="radio" style="width:295px" layout="pageDirection" >
        <f:selectItem itemValue="program" itemLabel="Series or Individual Program"/>
        <f:selectItem itemValue="promo" itemLabel="Promo" />
        <f:selectItem itemValue="specific" itemLabel="Specific Format Encoding Request"/>
        <a4j:support ajaxSingle="true" event="onclick" limitToList="true" reRender="program" eventsQueue="request1"/>
      </h:selectOneRadio>

       

      <a4j:outputPanel id="program">
        <s:span rendered="#{('program' == webencode.requestType || 'promo' == webencode.requestType) ? true : false}">
          <h:selectOneMenu value="#{webencode.seriesId}" id="lstSeriesName">
            <f:selectItems value="#{webencode.programItems}"/>
          </h:selectOneMenu>
        </s:span>
        <s:span rendered="#{'specific' == webencode.requestType ? true : false}">
          <h:selectOneMenu value="#{webencode.arrVideoEncodings.get(0).videoEncoding}"
            id="lstSpecificVideoEncoding1" style="width:295px;">
            <f:selectItems value="#{webencode.videoEncodingItems}"/>
          </h:selectOneMenu>
        </s:span>
      </a4j:outputPanel>              

       

      When the value in the above selectOneRadio is changed, it erases the value of the txtLibraryServerNumber field in the outputPanel below; for the life of me, I don't know what's going on:

       

      <h:selectOneMenu value="#{webencode.inputMediaType}"
        id="lstInputMediaType">
        <f:selectItems value="#{webencode.inputMediaTypeItems}"/>
        <a4j:support ajaxSingle="true" event="onchange" reRender="media" limitToList="true" eventsQueue="media1"/>
      </h:selectOneMenu>

       

      <a4j:outputPanel id="media">
        <s:span rendered="#{'Tape Library # or Server ID #' == webencode.inputMediaType ? true : false}">
          <h:inputText id="txtLibraryServerNumber"
            value="#{webencode.libraryServerNumber}" maxlength="50" />

        </s:span>   
        <s:span rendered="#{'Digital Media File Name' == webencode.inputMediaType ? true : false}">
          <h:inputText id="txtDigitalMediaFileName"
            value="#{webencode.digitalMediaFileName}" maxlength="195" /><br />
        </s:span>   
      </a4j:outputPanel>

        • 1. Re: a4j:support controls interfere with each other
          Alex Cougarman Apprentice
          Additional info: If I click the submit button and have validation errors displayed, the value of the txtLibraryServerNumber field sticks even when I click the selectOneRadio. It's like the other way, the value is not being written to the backing bean. What do I need to do to ensure the value of the text field is written to the backing bean when I click the selectOneRadio?
          • 2. Re: a4j:support controls interfere with each other
            Alex Cougarman Apprentice

            Found a solution: Changed both panel's and it all works fine --

             

            <a4j:outputPanel id="program" ajaxRendered="false">

            ......

            </a4j:outputPanel>

             

            <a4j:outputPanel id="media" ajaxRendered="false">

            ......

            </a4j:outputPanel>

             

            Apparently, the AJAX call from one a4j:support was causing the other panel to be refreshed before its controls' values had been written server-side to the bean. It only took all day. Hope this helps others with this headache.

            • 3. Re: a4j:support controls interfere with each other
              Ilya Shaikovsky Master
                <a4j:support ajaxSingle="true" event="onclick" limitToList="true" reRender="program"

              ajaxSingle defines only parent select for processing. So any changes in input will be reseted as new values will not be processed on requests. You could add the input to the process attribute if need to proces together with the select.

              • 4. Re: a4j:support controls interfere with each other
                Alex Cougarman Apprentice

                Thanks, Ilya. I've made the change you suggested, but still not getting the expected result -- the value of the text field is still erased when the radio buttons are clicked. Here's the changed code. What am I missing?

                 

                <h:selectOneRadio value="#{webencode.requestType}"
                  id="rdoRequestType" styleClass="radio" style="width:295px" layout="pageDirection" >
                  <f:selectItem itemValue="program" itemLabel="Series or Individual Program"/>
                  <f:selectItem itemValue="promo" itemLabel="Promo" />
                  <f:selectItem itemValue="specific" itemLabel="Specific Format Encoding Request"/>
                  <a4j:support ajaxSingle="true" event="onclick" reRender="program" process="txtLibraryServerNumber,txtDigitalMediaFileName"/>
                </h:selectOneRadio>

                <a4j:outputPanel id="program" ajaxRendered="true">
                  <s:span rendered="#{('program' == webencode.requestType || 'promo' == webencode.requestType) ? true : false}">
                    <h:selectOneMenu value="#{webencode.seriesId}" id="lstSeriesName">
                      <f:selectItems value="#{webencode.programItems}"/>
                    </h:selectOneMenu>
                  </s:span>
                  <s:span rendered="#{'specific' == webencode.requestType ? true : false}">
                    <h:selectOneMenu value="#{webencode.arrVideoEncodings.get(0).videoEncoding}"
                      id="lstSpecificVideoEncoding1" style="width:295px;">
                      <f:selectItems value="#{webencode.videoEncodingItems}"/>
                    </h:selectOneMenu>
                  </s:span>
                </a4j:outputPanel>             

                <h:selectOneMenu value="#{webencode.inputMediaType}"
                  id="lstInputMediaType">
                  <f:selectItems value="#{webencode.inputMediaTypeItems}"/>
                  <a4j:support ajaxSingle="true" event="onchange" reRender="media" process="lstSeriesName,lstSpecificVideoEncoding1"/>
                </h:selectOneMenu>

                <a4j:outputPanel id="media" ajaxRendered="true">
                  <s:span rendered="#{'Tape Library # or Server ID #' == webencode.inputMediaType ? true : false}">
                    <h:inputText id="txtLibraryServerNumber"
                      value="#{webencode.libraryServerNumber}" maxlength="50" />
                  </s:span>  
                  <s:span rendered="#{'Digital Media File Name' == webencode.inputMediaType ? true : false}">
                    <h:inputText id="txtDigitalMediaFileName"
                      value="#{webencode.digitalMediaFileName}" maxlength="195" /><br />
                  </s:span>  
                </a4j:outputPanel>

                • 5. Re: a4j:support controls interfere with each other
                  Alex Cougarman Apprentice

                  Hi, folks. I'm running out of time on this problem. Anyone have any way to fix the broken code above? Your help is much appreciated.

                  Thanks.

                  • 6. Re: a4j:support controls interfere with each other
                    Nick Belaevski Master
                    Jut to clarify: are all inputs located in the same form?
                    • 7. Re: a4j:support controls interfere with each other
                      Alex Cougarman Apprentice
                      Yes, all inputs are in the same form.