7 Replies Latest reply on Feb 19, 2008 12:33 AM by <todo> <todo>

    ajaxSingle="true" submits form

    Alexander Belov Novice

      I use a4j:commandButton with attribute ajaxSingle="true" and type="reset". And parent form of this component has javascript code on event "onsubmit".

      Well, then I click at a4j:commandButton, javascript function on parent form is called.

      Is it a bug?

      I use RichFaces 3.1.4 GA, JSF 1.2_07 RI.

      Script function of command button is the following:

      A4J.AJAX.Submit('_viewRoot','j_id28:include:editM2PropertiesForm',event,{'affected':['j_id28:include:editM2PropertiesForm:editM2PropertiesPageContainer'] ,'oncomplete':function(request,event,data){return true;},'parameters':{'j_id28:include:editM2PropertiesForm:m2PropertiesCancel':'j_id28:include:editM2PropertiesForm:m2PropertiesCancel'} ,'actionUrl':'/amscAdmin/selfcareadmin.jsf?javax.portlet.faces.DirectLink=true'} )

      Command button has id="m2PropertiesCancel", form has id="editM2PropertiesForm".

      As I see in script function, all form is submitted? Is it true?

        • 1. Re: ajaxSingle=
          Ilya Shaikovsky Master

          why are you useing a4j:command to implement reset button? why not just h:command?

          • 2. Re: ajaxSingle=
            Alexander Belov Novice

            I want to reset values and tell server about it (call Java function by action attribute). Besides, I use oncomplete attribute to call javascript function.

            I have tried to use h:commandLink of type "reset" with a4j:support. The result is the same.

            I tryed to use a4j:commandButton without type="reset", without type="reset" and bypassUpdates="true". But ajax request submits form, it's javascript event is fired.

            • 3. Re: ajaxSingle=
              Alexander Belov Novice

              In my case I have a form and 3 buttons. First button let user to edit values. It sends ajax request to make all components of form enabled (they are disabled by default). Second button submits all made changes. And the third button is "Cancel". It must revert all changes and set all component to disabled state.

              Besides, I use custom client validation framework. It sets up form by providing it onsubmit event.

              I use a4j:commandButton to send request with the third button. And this way client side validation works, because form onsubmit event is called.

              • 4. Re: ajaxSingle=
                Ilya Shaikovsky Master

                look.. seems a4j:commandButton performs request with type="reset" also... It's a problem but I think its minor...

                How do you think partial reset should works? :) You may use h:commandButton with type ="reset" . It will works as expected without any request only reseting form. We able to make a4j:control works in the same way.. But as I understand you need to perform submit? so onsubmit will be fired at any request. So if I right this fix will not be usefull for your case. a4j:button should not be used with reset type.

                • 5. Re: ajaxSingle=
                  <todo> <todo> Newbie

                  I think that a4j:commandButton shouldn't perform request with type="reset". It should work as h:commandButton with the same attribute.

                  Please, tell me, why onsubmit will be fired on request. Is it mandatory to submit one value? Or you need it to send ViewState?

                  • 6. Re: ajaxSingle=
                    Ilya Shaikovsky Master

                    1) So use h:commandButton. It works like you need.

                    2) it's mandatory to call onsubmit because it's normal submit bewhaviour. Processing limited on server side (decode, validation, applying values, optionally encoding). But form submitted as usually on request. And onsubmit function will be called.

                    • 7. Re: ajaxSingle=
                      <todo> <todo> Newbie

                      Thank you for your answer. I'll use workaround.