1

HTML/JS Code:

<form id="myform" action="<portlet:actionURL/>" method="GET">
    <input type="hidden" id="val" name="val"/> 
    <input type="submit" onClick="Go()" value="Go">
</form>

<script>
function search() {
    document.getElementById("val").value = "MYVALUE";
    document.getElementById("myform").submit();
}
</script>

Java Code:

@Override
public void processAction(ActionRequest request, ActionResponse response)
            throws PortletException, IOException {
     System.out.println("SHOULD REACH HERE");
}

IF I change the method to post in HTML, I reach the process action but not with GET method. Can some one please point me how can i submit a GET request in liferay?

Thanks/

webExplorer
  • 1,025
  • 2
  • 17
  • 33

2 Answers2

0

This is your browser behaving according to the spec, not Liferay-related at all: If you look at the Action URL, it contains a questionmark and some parameters. Upon sending the form, they will be eliminated, replaced by the parameters in your input fields.

Instead of going through the reasoning and linking the spec, find several answers and explanations within this related stackoverflow question

There are also workarounds based on javascript. However, as processAction might actually change your state, it's a good idea to have it on POST actions typically. But now that you know the reason, you should be able to work around.

Community
  • 1
  • 1
Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
-1

Hi use following code in portlet action class

protected boolean isCheckMethodOnProcessAction() {
              return _CHECK_METHOD_ON_PROCESS_ACTION;
        }
private static final boolean _CHECK_METHOD_ON_PROCESS_ACTION = false;

But its not recommended for action url.

Meera Prince
  • 177
  • 3