Wednesday, May 30, 2012

grails portlet plugin actionView not invoked

Problem:


I was using the Grails plugin for creating Portlets found here: http://grails.org/plugin/portlets

I created the Portlet code by invoking the following command: 
grails create-portlet MyFirst

This automatically created the Portlet class which contains the following code snippet:


    def actionView = {
        //TODO Define action phase for 'view' portlet mode
        portletResponse.setRenderParameter("prp-1", "value-1");
    }

The following the instructions as documented, I invoke the following command to generate the view for the portlet:

grails generate-portlet-views com.company.MyFirst
It creates several files with one of them being the view.gsp file. This file has a snippet as shown:


<form action="${portletResponse.createActionURL()}">
    <input type="submit" value="Submit"/>
</form>


The trouble was, when I goto submit the form, the actionView method never gets invoked. Only the renderView method get's invoked:

Solution 

The problem was that the form did not declare a POST method. I modified the view.gsp as follows:


<form action="${portletResponse.createActionURL()}" method="post">
    <input type="submit" value="Submit"/>
</form>

Reference:

 

No comments:

Post a Comment