"> ">
Download presentation
Presentation is loading. Please wait.
Published byFerdinand Morrison Modified over 9 years ago
1
Struts Portlet Redirect Copyright © 2000-2006 Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission from Liferay, Inc.
2
Objective The goal of this tutorial is to prevent multiple submits 1.Update existing JSP file –view.jsp 2.Add page flow path –struts-config.xml 3.Update Action to handle redirect –AddBookAction.java
3
view.jsp Add this hidden form field redirect" type="hidden" value=" ">
4
struts-config.xml Lets add /ext/library/success so that we have a landing path
5
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"); Add this line to the code res.sendRedirect(req.getParameter("redirect"));
6
AddBookAction.java What is “redirect”? “redirect” is the name of the hidden field we added to view.jsp res is the response object sendRedirect is an portlet method that grabs a request value from either the querystring or form submit. It than redirects to the redirect value Make sure that your redirect value is a valid URL
7
Deploy the Files to Tomcat Deploy files to Tomcat once you are finished Open up a cmd prompt –Click “Start”, “Run” and then type “cmd” Navigate to your ext directory and then type “ant deploy” …\ext>ant deploy
8
Final Steps 1.Restart Tomcat 2.Open up a new browser and type http://localhost:8080 LOGIN: test@liferay.com PASSWORD: test
9
Review Key Concepts Add a hidden “redirect” form field to view.jsp “redirect” is the URL of the view.jsp Make sure that the path exist in struts-config.xml In your java, replace your forward path with a sendRedirect path.
10
Revision History Jerry Niu9/13/2006-9/14/2006 Slide create and updates
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.