5 Replies Latest reply on Jan 30, 2009 7:19 PM by nbelaevski

    how to have one forms action force another form to do ajax s

    jhaley

      I have two forms on the same page; let's say Form A and Form B. On particular actions inside form A I want to have Form B use ajax to update it's bean values before the action is invoked. I was thinking the a4j:jsFunction may help me do this, but I'm not clear on how.

      I did think about placing everything in the same form, but this create some other issues.

        • 1. Re: how to have one forms action force another form to do aj

          Do you mean you want the formB submitted before the formB submitted and date submitted with formB should be available in the action invoked by formA?

          Is the formA submitted with Ajax or it is a regular request?

          • 2. Re: how to have one forms action force another form to do aj
            jhaley

            I want Form B submitted before Form A is submitted, reason being is that Form A rerenders Form B and my modified Form B values are getting lost. I'm a little confused by what you mean by date submitted. All submissions are Ajax Submissions

            I may have just figured out how to do it, I'm still doing some testing.

            I made Form B be a a4j:form and added ajaxSubmit='true'

            <a4j:form ajaxSubmit="true" >



            In Form B I added a submit Form A from a button's onclick event
            <a4j:commandLink value="add" actionListener="#{roomCtrl.addArticle}" reRender="partOfFormA" onclick="document.formA.submit(); />


            • 3. Re: how to have one forms action force another form to do aj

              You have one big pile. Hard to suggest something here.

              1. ajaxSubmit="false" does not make sense you you have a4j:commandLink in this form

              2. onclick="document.formA.submit();" launches the non-ajax request with replacing the whole page with request. The Ajax request from the a4j:commandLink will be aborted somewhere in the middle due to that request. The result is unpredictable. Maybe request from formB will be aborted before sending and nothing changed on the server. In case it had a time to come to the server, the result will be also unpredictable because nobody guaranties which of two requests sent almost in parallel will be first on each of the JSF lifecycle phase.

              • 4. Re: how to have one forms action force another form to do aj
                nbelaevski

                 

                "jhaley" wrote:
                I have two forms on the same page; let's say Form A and Form B. On particular actions inside form A I want to have Form B use ajax to update it's bean values before the action is invoked. I was thinking the a4j:jsFunction may help me do this, but I'm not clear on how.

                I did think about placing everything in the same form, but this create some other issues.


                So, what is the problem? Put a4j:jsFunction into the second form and call it in the client event handler of the first form. Add eventsQueue attribute with the same value to both jsFunction and action component in order to handle requests serially...

                • 5. Re: how to have one forms action force another form to do aj
                  nbelaevski

                  P.S. You may take a look at this: https://jira.jboss.org/jira/browse/RF-5842