KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > mlw > vlh > web > tag > support > LiferayPortletLinkEncoder


1 /**
2  * Copyright (c) 2003 held jointly by the individual authors.
3  *
4  * This library is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published
6  * by the Free Software Foundation; either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; with out even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation,
16  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  *
18  * > http://www.gnu.org/copyleft/lesser.html
19  * > http://www.opensource.org/licenses/lgpl-license.php
20  */

21 package net.mlw.vlh.web.tag.support;
22
23 import javax.portlet.PortletURL;
24 import javax.portlet.RenderResponse;
25 import javax.servlet.ServletRequest JavaDoc;
26 import javax.servlet.jsp.PageContext JavaDoc;
27
28 /** This LinkEncoder encodes a URL to the standards defined
29  * in the JSR168 Portlet API.
30  *
31  * The Liferay portal with their Struts based
32  * portlet that isn't quite JSR168... so this encoder appends
33  * the struts_action parameter.
34  *
35  * To use this class an entry needs to be made in the spring.xml file:
36     <pre>
37       ...
38       <bean id="classicLook" singleton="true" class="net.mlw.vlh.web.ValueListConfigBean">
39         ...
40         <property name="linkEncoder">
41           <bean class="net.mlw.vlh.web.tag.support.LiferayPortletLinkEncoder">
42             <property name="strutsSupport"><value>{true|false}</value></property>
43           </bean>
44         </property>
45         ...
46       </bean>
47       ...
48     </pre>
49  *
50  * @author Keith R. Davis
51  * @version $Revision: 1.3 $ $Date: 2004/08/17 15:30:51 $
52  */

53 public class LiferayPortletLinkEncoder extends PortletLinkEncoder
54 {
55     private boolean strutsSupport = true;
56
57     public PortletURL getRenderURL(PageContext JavaDoc pageContext)
58     {
59         ServletRequest JavaDoc request = pageContext.getRequest();
60         RenderResponse renderResponse = (RenderResponse) request.getAttribute("javax.portlet.response");
61         PortletURL url = renderResponse.createRenderURL();
62
63         if (strutsSupport)
64         {
65             url.setParameter("struts_action", (String JavaDoc) request.getAttribute("struts_action"));
66         }
67
68         return url;
69     }
70
71     /**
72      * @return Returns the strutsSupport.
73      */

74     public boolean isStrutsSupport()
75     {
76         return strutsSupport;
77     }
78
79     /**
80      * @param strutsSupport The strutsSupport to set.
81      */

82     public void setStrutsSupport(boolean strutsSupport)
83     {
84         this.strutsSupport = strutsSupport;
85     }
86 }
Popular Tags