liferay tutorial

Thursday, March 31, 2011

struts portlet tutorial, struts portlet, Irshad Mansuri

Prepared by Aasif and Ahmed under the guidance of Irshad Mansuri

Attune Infocom
----------------------------------------------------------------------------------
===============================================================
6. Struts Portlet - Adding Redirect to avoid duplicate insertion
===============================================================

6.1 update struts-config.xml
----------------------------

add /ext/library/success so that we have a landing path

(location "ext/ext-web/docroot/WEB-INF")

<action path="/ext/library/success" forward="portlet.ext.library.success" />

run "ant deploy" from "ext-web"


6.2 update AddBookAction.java
-----------------------------

* We are going to modify our java to use a redirect instead of a forward
* A forward still submits to the page that it lands on. But a redirect will no longer retain the submit state on the landing page

Comment out the forward line
//setForward(req, "portlet.ext.library.success");

replace with these lines

PortletURL redirectURL = ((ActionResponseImpl) res).createRenderURL();
redirectURL.setParameter("struts_action", "/ext/library/success");
res.sendRedirect(redirectURL + "&title=" + bookTitle);

Make necessary imports


6.3 ant deploy
--------------

ant deploy from "ext-impl", re-start server and check the previous problem is not happening anymore.

6.4 Exercise
------------

What changes are required if we dont want to display the book title in the success.jsp file.

No comments:

Post a Comment