9 Replies Latest reply on Dec 3, 2007 3:37 AM by jimmy6

    ajaxSingle vs <a4j:ajaxRegion>

      Hi all,

      Could someone explain what the different bettwen ajaxSingle and <a4j:region> is please.

      I have a simple form with two <h:selectOneMenu> items. I want one to change its contents based on the selection of the other.

      I did the following:

      <h:selectOneMenu ...>
       <a4j:support event="onchange" reRender="menu2" ajaxSingle="true"/>
      </h:selectOneMenu>
      
      <h:selectOneMenu id="menu2" .../>
      


      And it was still validating and updating the model for menu2.

      When I changed it to the following it worked as expected.

      <a4j:region renderRegionOnly="false">
       <h:selectOneMenu ...>
       <a4j:support event="onchange" reRender="menu2" ajaxSingle="true"/>
       </h:selectOneMenu>
      </a4j:region>
      
      <h:selectOneMenu id="menu2" .../>
      


      With only the first menu getting its model updated. I'm not sure what ajaxSingle does then? Am I missing something?

      Cheers.

      Mike.


        • 1. Re: ajaxSingle vs <a4j:ajaxRegion>

          what the JSF implementation you use?

          • 2. Re: ajaxSingle vs <a4j:ajaxRegion>

            Hi there,

            JSF RI 1.2_02 is the JSF implementation. I'm using Ajax4Jsf 1.1.0.

            Noticed I mis-pasted one of the examples, ajaxSingle was removed in the second example. Should read below...

            <a4j:region renderRegionOnly="false">
             <h:selectOneMenu ...>
             <a4j:support event="onchange" reRender="menu2"/>
             </h:selectOneMenu>
            </a4j:region>
            
            <h:selectOneMenu id="menu2" .../>
            


            Cheers.

            Mike.


            • 3. Re: ajaxSingle vs <a4j:ajaxRegion>

              renderRegionOnly is "false" by default since ajax4jsf 1.1.0 . So, you can avoid it now.

              ajaxSingle directs to include only the particular field to the request string (along with other jsf related data)

              a4j:region does not limit the request data (the whole form is transfered). However, a4j:region limits the area of the component tree to be processed.

              in case of just ajaxSingle, the whole tree is processed. This causes the validation triggered on the selectOneMenu.

              • 4. Re: ajaxSingle vs <a4j:ajaxRegion>

                P.S. I have added new issue to Jira:
                http://jira.jboss.com/jira/browse/AJSF-30

                There are too many cases when developers do not expect the behavior.

                • 5. Re: ajaxSingle vs <a4j:ajaxRegion>

                  OK I understand now, thanks for clearing that up.

                  Is the JIRA issue intended to change ajaxSingle so it behaves as if the parent component was wrapped with <a4j:region/>

                  The obvious use case is the above where control(s) needs to change it's options/value based on the selection of another. It would be cool if ajaxSingle just did submission AND processing of a single field. I can't actually see a case where I would want a single field submission but then want to process the whole tree.

                  Cheers.

                  Mike.

                  • 6. Re: ajaxSingle vs <a4j:ajaxRegion>

                     

                    "quilleashm" wrote:
                    I can't actually see a case where I would want a single field submission but then want to process the whole tree.


                    So, do I. Therefore, we suggest that ajax4jsf will surround such component with a4j:region implicitly. This is what jira issue presume.

                    P.S. It might be a use case when you need to send and process this field and couple more fields from the form, but not the whole form. However, it is another store.

                    • 7. Re: ajaxSingle vs <a4j:ajaxRegion>

                       

                      It would be cool if ajaxSingle just did submission AND processing of a single field.


                      I agree with this also and need this to improve the performance. That is because i got the a4j:status. That is why i need a4j:region to wrap all the control but i do not want it to process all the uicomponent. It is because i use bypassupdate to do validation. It will trigger all my query in the get method...

                      • 8. Re: ajaxSingle vs <a4j:ajaxRegion>

                        What is single field? Does any component, even very complicated, must have one and only one input or hidden field to submit its value?
                        RichFaces is designed not only work correctly with input primitives.

                        • 9. Re: ajaxSingle vs <a4j:ajaxRegion>

                          But they already did this with feature in a4j 1.2.