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?
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....
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.
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.
Thanks Trong - you are correct. If I submit the form using GET, the URL looks like:
If I submit the form using POST, the URL looks like:
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!