Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sebastian Monte
Fire action request before render?
January 31, 2012 10:37 AM
Answer

Sebastian Monte

Rank: New Member

Posts: 2

Join Date: January 31, 2012

Recent Posts

I have a simple need, to execute action request before the default render method takes place. This seems to be rather impossible to achieve...

Use case:

I have a portlet on a layout. That portlet needs to send a redirect to a completely new page, if some conditions are met. However, how can I congfigure the portlet so that when it is rendered in the layout, the action method is processed as default. I'm using Spring portlets.

The following does not work:

 1
 2        @ActionMapping
 3    public void init(ActionRequest request, ActionResponse resposen) {
 4        ...
 5    }
 6
 7    @RenderMapping
 8    public ModelAndView home(RenderRequest request, RenderResponse response) {
 9              ...
10        }


I have tried to put the following in friendly URLs

1
2<routes>
3    <route>
4        <pattern></pattern>
5        <ignored-parameter name="p_p_lifecycle"/>
6        <overridden-parameter name="p_p_lifecycle">1</overridden-parameter>
7    </route>
8</routes>
David H Nebinger
RE: Fire action request before render?
January 31, 2012 12:47 PM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6693

Join Date: September 1, 2006

Recent Posts

Render is called upon first display of the portlet.

Action is only called when the user invokes some action in the portlet. After the action is complete, the render phase is invoked again.

This is the JSR 168 standard for the portlet lifecycle. Liferay implements and supports the standard.

You are trying to violate the standard and do something that is unsupported.

Perhaps some alternative would be more appropriate?
Sebastian Monte
RE: Fire action request before render?
January 31, 2012 11:04 PM
Answer

Sebastian Monte

Rank: New Member

Posts: 2

Join Date: January 31, 2012

Recent Posts

Thank you for your reply.

Yes, alternatives are always welcome. Basically I just have a need to redirect to another page if some conditions are met. Is there some request / layout hook that I could use before the portlet is in its render phase? Javascript redirection is not really an option, since it's not SEO friendly and users do not have JS always on.
Arvind Gupta
RE: Fire action request before render?
June 27, 2013 3:41 AM
Answer

Arvind Gupta

Rank: Junior Member

Posts: 29

Join Date: December 17, 2012

Recent Posts

Did you get the solution if yes , please share.