Author: taylor Date: Thu Mar 23 15:33:32 2006 New Revision: 388298 URL: http://svn.apache.org/viewcvs?rev=388298&view=rev Log: pass on portlet entity to javascript function
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java?rev=388298&r1=388297&r2=388298&view=diff ============================================================================== --- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java (original) +++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java Thu Mar 23 15:33:32 2006 @@ -15,16 +15,26 @@ */ package org.apache.jetspeed.container.url.impl; +import java.io.UnsupportedEncodingException; +import java.util.Map; import java.util.StringTokenizer; +import javax.portlet.PortletMode; +import javax.portlet.WindowState; import javax.servlet.http.HttpServletRequest; import org.apache.jetspeed.PortalContext; import org.apache.jetspeed.container.state.NavigationalState; import org.apache.jetspeed.container.url.BasePortalURL; +import org.apache.pluto.om.window.PortletWindow; /** - * PathInfoEncodingPortalURL encodes the NavigationalState as PathInfo element + * DesktopEncodingPortalURL encodes URLs as javascript calls + * The signature for the javascript call is based on teh constructor argument <code>javascriptDoRender</code> + * The script method requires two parameters: + * 1. URL the portlet pipeline URL + * 2. the entity id of the portlet to render + * Example URL for a javascript method doRender: <code>doRender("http://localhost/jetspeed/portlet", "33")</code> * * * @author <a href="mailto:[EMAIL PROTECTED]">Ate Douma</a> * @version $Id: PathInfoEncodingPortalURL.java 367856 2006-01-11 01:04:09Z taylor $ @@ -101,6 +111,11 @@ } protected String createPortletURL(String encodedNavState, boolean secure) + { + return createPortletURL(encodedNavState, secure, null); + } + + protected String createPortletURL(String encodedNavState, boolean secure, PortletWindow window) { StringBuffer buffer = new StringBuffer(""); if (this.javascriptDoRender != null) @@ -120,10 +135,32 @@ { buffer.append(getPath()); } - if (this.javascriptDoRender != null) + if (this.javascriptDoRender != null) { - buffer.append("\")"); + if (window != null) + { + buffer.append("\",\""); + buffer.append(window.getPortletEntity().getId()); + buffer.append("\""); + } + buffer.append(")"); } return buffer.toString(); } + + public String createPortletURL(PortletWindow window, Map parameters, PortletMode mode, WindowState state, boolean action, boolean secure) + { + try + { + return createPortletURL(this.getNavigationalState().encode(window,parameters,mode,state,action), secure, window); + } + catch (UnsupportedEncodingException e) + { + // should never happen + e.printStackTrace(); + // to keep the compiler happy + return null; + } + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]