4 Replies Latest reply on Mar 29, 2011 9:21 AM by rraposa

    Can I submit a form using GET for processAction?

    rraposa

      I have a method in my portlet that is annotated with @ProcessAction and a form whose action points to my portlet. If I submit the form using POST, then my @ProcessAction method gets invoked and everything works fine.

       

      However, if I switch the form's submission method to GET, then my ProcessAction method does not get invoked on my portlet. I don't see in the spec where this should only work for POST. Anyone familiar with this issue?

       

      Thanks!

      Rich

        • 1. Re: Can I submit a form using GET for processAction?
          hoang_to

          I think the explaination comes from the protocol used for request handling.

           

          1. When user interacts with portlets, ActionRequest is sent

           

          2. ActionRequest handling (reset the state of portlet window,...) eventually results in EventRequest

           

          3. Once all EventRequest have been processed, RenderRequest is sent to each portlet

           

          ( You could see the sequential diagram in page 43 of the spec)

           

          We learn that ActionRequest is not designed to retreive data, whereas the GET HTTP is designed to get data....

          • 2. Can I submit a form using GET for processAction?
            rraposa

            That is good information, but I don't quite see what different it should make behind-the-scenes whether or not the request is GET vs. POST. I'm sure there is a good reason for it - but if not, it should be something that perhaps we can change.

             

            Here is my use-case: I have a form with dozens of options and I want the users to be able to bookmark the page that displays the results so they can come back later and not re-enter the form criteria, or email the link to themselves, so I want to submit the form using GET.

            • 3. Re: Can I submit a form using GET for processAction?
              trong.tran

              Actually the ProcessAction does not care about whatever it's the POST or GET.

               

              The problem here is that the agent ( browser ) send requests in POST and GET in different target URL. Let say that in the form you have action="/portal/private/classic/test?foo=bar" and an input with name/value :

               

              1/ if the form is sent by POST, the target URL will be kept as whole value in the action, that is "/portal/private/classic/test?foo=bar".

               

              2/ if it's sent by GET, the target URL will be re-composed by taking only "/portal/private/classic/test" part from the value of the action ( which is before "?" ) AND plus with name/value of the inputs converted as query string. That is "/portal/private/classic/test?name=value".

               

              In the case with GET, it's losing some information identified by Portal to know where exactly the request sent to. That's why the ProcessAction will not invoked.

               

              I'm not sure if this behaviour should be identified/handled by Portal itself BUT absolutely you could treat it with Javascript somehow to get your usecase work

              • 4. Can I submit a form using GET for processAction?
                rraposa

                Thanks Trong - you are correct. If I submit the form using GET, the URL looks like:

                http://localhost:8080/portal/private/councilbluffs/home?lowPrice=min&highPrice=max&bedrooms=any&bathrooms=any&submit=Search

                 

                If I submit the form using POST, the URL looks like:

                http://localhost:8080/portal/private/councilbluffs/home?portal:componentId=d21b34df-2962-4d89-a1a7-aa93629ddbe4&portal:type=action&portal:isSecure=false&interactionstate=JBPNS_rO0ABXcwABRqYXZheC5wb3J0bGV0LmFjdGlvbgAAAAEAC2hvbWVfc2VhcmNoAAdfX0VPRl9f

                 

                To clarify, the value of "action" in the <form> tag is the same for both, but the browser is rewriting the URL before sending it and clearly removing the important information about which portlet to send the request to.

                 

                I will research how others have designed portal pages that can be bookmarked. Thanks for your help!

                1 of 1 people found this helpful