Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Struts portlet life cycle and developping rules
hello! I am having some doubts about developing principles or basic rules for developping portlets and I am sure that your view will help me a lot.
We are using struts for our developments, and to start we use the sample struts portlets that we can find in the liferay wiki.
There are 2 samples for struts 1.x with a big difference. Sample-struts-portlet's actions extends from org.apache.struts.action.Action and implement the execute method. In the other side, Sample-struts-liferay-portlet's actions extends from com.liferay.portal.struts.PortletAction which extends from org.apache.struts.action.Action, but they implement the processAction and render methods. Which example should I use to start my development?
I have been using the first aproach, because it is not so dependant of liferay (it doest not use liferay imports, only struts's), but I think that this way I am not really following the jsr-168 or 268 scpecification or the portlet life cycle, right? and then it is not easy to use some portlet functionalities as the inter portlet communication (for example with events, we are able to listen to events implementing a class extending com.liferay.portlet.StrutsPortlet, but we cant send the variable obtained in the event to the execute method of an action)
Another reason why we have used the first one, and not the second one, is because we dont want to refresh all the portlets in the page every time an action is executed. We are using maps in some portlets and we dont want them to go back to the start position when using neighbour portlets. Is it really required to refresh all the portlets in the page to follow the jsr-168 specification everytime an action is executed? I dont really understand why this is done...
what aproach are you using??
Thank you!
We are using struts for our developments, and to start we use the sample struts portlets that we can find in the liferay wiki.
There are 2 samples for struts 1.x with a big difference. Sample-struts-portlet's actions extends from org.apache.struts.action.Action and implement the execute method. In the other side, Sample-struts-liferay-portlet's actions extends from com.liferay.portal.struts.PortletAction which extends from org.apache.struts.action.Action, but they implement the processAction and render methods. Which example should I use to start my development?
I have been using the first aproach, because it is not so dependant of liferay (it doest not use liferay imports, only struts's), but I think that this way I am not really following the jsr-168 or 268 scpecification or the portlet life cycle, right? and then it is not easy to use some portlet functionalities as the inter portlet communication (for example with events, we are able to listen to events implementing a class extending com.liferay.portlet.StrutsPortlet, but we cant send the variable obtained in the event to the execute method of an action)
Another reason why we have used the first one, and not the second one, is because we dont want to refresh all the portlets in the page every time an action is executed. We are using maps in some portlets and we dont want them to go back to the start position when using neighbour portlets. Is it really required to refresh all the portlets in the page to follow the jsr-168 specification everytime an action is executed? I dont really understand why this is done...
what aproach are you using??
Thank you!
Hello,
I'd like to know if anyone ever came up with a solution to the "refreshing the entire page every time an action is executed" problem, mentioned in the post above.
I know this is an old post, but I am just getting started with Liferay, so most posts are new to me, and I think they may be new to others as well. So, if anyone knows how to fix this issue, please share the solution!
Thank you.
I'd like to know if anyone ever came up with a solution to the "refreshing the entire page every time an action is executed" problem, mentioned in the post above.
I know this is an old post, but I am just getting started with Liferay, so most posts are new to me, and I think they may be new to others as well. So, if anyone knows how to fix this issue, please share the solution!
Thank you.
Joaquin Rg u:
Is it really required to refresh all the portlets in the page to follow the jsr-168 specification everytime an action is executed? I dont really understand why this is done...
I believe so. If you send in an ActionRequest (or RenderRequest), the whole page refreshes. Otherwise, you can send in an AJAX request and that wouldn't refresh the page.