0 Replies Latest reply on Aug 30, 2011 3:11 AM by Nicholas Oxhøj

    Bug in <a4j:region> and the "process" attribute?

    Nicholas Oxhøj Newbie

      Hi,

       

      It seems to me that the <a4j:region> doesn't work correctly together withe the process="..." attribute on AJAX commands. Specifically you cannot process inputs outside the <a4j:region> even though you list them specifically in the process attribute.

       

      I have always thought that ajaxSingle and <a4j:region> were two functionally equivalent ways of specifying which inputs should be processed in the first phases of the JSF lifecycle - one is easy to use if you only want to process a single input and the other if you have a group of related inputs.

       

      In chapter 5.7.4. "Decide what to process" of the Richfaces 3.3.X documentation, it is stated that: The "process" attribute allows to define the ids of components to be processed together with the component which is marked as ajaxSingle or wrapped to region.

       

      As I understand this, the example in the documentation:

       

          <h:inputText value="#{bean.name}" id="name">

              <a4j:support ajaxSingle="true" process="email" event="onblur" reRender="someOut"/>

          </h:inputText>

          <h:inputTextarea value="#{bean.description}" id="desc" />

          <h:inputText value="#{bean.email}" id="email">

              <a4j:support ajaxSingle="true" process="name" event="onblur" reRender="someOut"/>

          </h:inputText>

       

      should be functionally equivalent to the following code:

       

          <a4j:region>

              <h:inputText value="#{bean.name}" id="name">

                  <a4j:support process="email" event="onblur" reRender="someOut"/>

             </h:inputText>

          </a4j:region>

          <h:inputTextarea value="#{bean.description}" id="desc" />

          <h:inputText value="#{bean.email}" id="email">

             <a4j:support ajaxSingle="true" process="name" event="onblur" reRender="someOut"/>

          </h:inputText>

       

      But this doesn't work as expected. The "email" component is no longer processed when focus leaves the "name" component.

       

      The reason for this is found in the class UIAjaxRegion, where all the "processing methods" (processDecodes, processValidators, and processUpdates) contains code similar to the following:

       

          if (ajaxContext.isAjaxRequest() && null != ajaxSingleClientId) {

              invokeOnComponent(context, ajaxSingleClientId, new ContextCallbackWrapper(updateCallback));

              Set<String> areasToProcess = ajaxContext.getAjaxAreasToProcess();

              if(null != areasToProcess){

                  for (String areaId : areasToProcess) {

                      invokeOnComponent(context, areaId, new ContextCallbackWrapper(updateCallback));

                  }

              }

          } else {

              super.processUpdates(context);

          }

       

      So the value of the process attribute (retrieved through ajaxContext.getAjaxAreasToProcess), is only used if the AJAX command has ajaxSingle="true". I don't understand why the "process" attribute isn't used, regardless of the value of the ajaxSingle attribute???

       

      Looking at the code, I thought that a workaround would the be to just add ajaxSingle="true" to the <a4j:support> so that it would again look like:

       

          <a4j:support ajaxSingle="true" process="email" event="onblur" reRender="someOut"/>

       

      But this doesn't work either. Although the code above will now enter the first branch and therefore loop through the areaIds specified in the process attribute, it will only find them if they are located inside the <a4j:region> itself, since the invokeOnComponent() is implicitely called on the  UIAjaxRegion.

       

      So the question is: Is this really the intended behavior and the (emphasized part of the) documentation is either wrong or I misunderstand it? Or is it (as I would think) a bug that I should submit to JIRA?

       

      Regards,

      Nicholas Oxhøj