JBoss Portal SVN: r9839 - in modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test: controller and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 14:11:18 -0500 (Thu, 07 Feb 2008)
New Revision: 9839
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
Log:
- allow other type of invocations in PortletURLRenderer (for page refresh)
- make the jsp portal use redirect after action
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-02-07 18:31:21 UTC (rev 9838)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-02-07 19:11:18 UTC (rev 9839)
@@ -34,10 +34,21 @@
}
/**
+ * The type of request. The goal is to allow other types of invocation to be used by the controller context.
+ * The controller context itself only works on the portlet type.
+ */
+ public static final String TYPE = "type";
+
+ /**
+ * The portlet type.
+ */
+ public static final String PORTLET_TYPE = "portlet";
+
+ /**
* The life cycle type of the invocation. The values accepted are <code>ACTION_LIFECYCLE</code>,
* <code>RENDER_LIFECYCLE</code> and <code>RESOURCE_LIFECYCLE</code>.
*/
- public static final String LIFECYCLE_TYPE = "type";
+ public static final String LIFECYCLE_PHASE = "lifecycle";
/** The window id. */
public static final String WINDOW_ID = "windowid";
@@ -70,12 +81,12 @@
public static final String RESOURCE_CACHEABILITY = "resourcecacheability";
/** Denotes an action lifecycle operation. */
- public static final String ACTION_LIFECYCLE = "action";
+ public static final String ACTION_PHASE = "action";
/** Denotes a render lifecycle operation. */
- public static final String RENDER_LIFECYCLE = "render";
+ public static final String RENDER_PHASE = "render";
/** Denotes a resource lifecycle operation. */
- public static final String RESOURCE_LIFECYCLE = "resource";
+ public static final String RESOURCE_PHASE = "resource";
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 18:31:21 UTC (rev 9838)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 19:11:18 UTC (rev 9839)
@@ -105,6 +105,9 @@
/** . */
private final StateControllerContextImpl stateControllerContext;
+ /** . */
+ private final PageNavigationalState pageState;
+
public AbstractPortletControllerContext(
HttpServletRequest req,
HttpServletResponse resp,
@@ -114,28 +117,29 @@
StateControllerContextImpl tmp = new StateControllerContextImpl(this);
// The nav state provided with the request
+ // Unmarshall portal navigational state if it is provided
PageNavigationalState pageState = null;
+ String context = req.getParameter(PAGE_STATE);
+ if (context != null)
+ {
+ byte[] bytes = Base64.decode(context, true);
+ pageState = tmp.unserialize(bytes, false);
+ }
+ // The type of invocation
+ String type = req.getParameter(TYPE);
+
+ // Process only portlet type
// The request decoded if not null
ControllerRequest request = null;
+ if (PORTLET_TYPE.equals(type))
+ {
+ // Get the window id
+ String windowId = req.getParameter(WINDOW_ID);
- // Get the window id
- String windowId = req.getParameter(WINDOW_ID);
-
- // Process
- if (windowId != null)
- {
// Helper
WebRequest ri = new WebRequest(req);
- // Unmarshall portal navigational state if it is provided
- String context = req.getParameter(PAGE_STATE);
- if (context != null)
- {
- byte[] bytes = Base64.decode(context, true);
- pageState = tmp.unserialize(bytes, false);
- }
-
//
Mode mode = null;
if (req.getParameter(MODE) != null)
@@ -162,8 +166,8 @@
WindowNavigationalState windowNavigationalState = new WindowNavigationalState(navigationalState, mode, windowState);
//
- String type = req.getParameter(LIFECYCLE_TYPE);
- if (RESOURCE_LIFECYCLE.equals(type))
+ String phase = req.getParameter(LIFECYCLE_PHASE);
+ if (RESOURCE_PHASE.equals(phase))
{
StateString resourceState = ParametersStateString.create(req.getParameter(RESOURCE_STATE));
String resourceId = req.getParameter(RESOURCE_ID);
@@ -212,7 +216,7 @@
}
else
{
- if (ACTION_LIFECYCLE.equals(type))
+ if (ACTION_PHASE.equals(phase))
{
ParameterMap formParameters = null;
if (ri.getBody() instanceof Body.Form)
@@ -254,8 +258,14 @@
this.resp = resp;
this.servletContext = servletContext;
this.stateControllerContext = tmp;
+ this.pageState = pageState;
}
+ public PageNavigationalState getPageState()
+ {
+ return pageState;
+ }
+
public ControllerRequest getRequest()
{
return request;
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 18:31:21 UTC (rev 9838)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 19:11:18 UTC (rev 9839)
@@ -27,7 +27,6 @@
import org.jboss.portal.common.io.Serialization;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
-import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.Base64;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.ContainerURL;
@@ -38,14 +37,13 @@
import org.jboss.portal.portlet.cache.CacheLevel;
import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.test.StringCodec;
import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -58,9 +56,6 @@
final StateControllerContextImpl stateContext;
/** . */
- final String windowId;
-
- /** . */
final HttpServletRequest clientReq;
/** . */
@@ -72,18 +67,16 @@
public PortletURLRenderer(
StateControllerContextImpl stateContext,
PageNavigationalState pageNS,
- String windowId,
HttpServletRequest clientReq,
HttpServletResponse clientResp)
{
this.stateContext = stateContext;
this.pageNS = pageNS;
- this.windowId = windowId;
this.clientReq = clientReq;
this.clientResp = clientResp;
}
- public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ private String renderURL(Map<String, String> parameters, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
CharBuffer buffer = new CharBuffer();
buffer.append(clientReq.getScheme());
@@ -101,30 +94,68 @@
}
//
+ boolean first = true;
+ for (Map.Entry<String, String> entry : parameters.entrySet())
+ {
+ String name = entry.getKey();
+ String value = entry.getValue();
+ buffer.append(first ? '?' : '&');
+ buffer.append(name, FastURLEncoder.getUTF8Instance());
+ buffer.append('=');
+ buffer.append(value, FastURLEncoder.getUTF8Instance());
+ first = false;
+ }
+
+ //
+ String url = buffer.asString();
+ return clientResp.encodeURL(url);
+ }
+
+ public String renderURL(Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ String pageState = null;
+ if (pageNS != null)
+ {
+ byte[] bytes = stateContext.serialize(pageNS);
+ pageState = Base64.encodeBytes(bytes, true);
+ }
+
+ //
+ Map<String, String> parameters = Collections.singletonMap(PAGE_STATE, pageState);
+
+ //
+ return renderURL(parameters, wantSecure, wantAuthenticated, relative);
+ }
+
+ public String renderURL(String windowId, ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
Map<String, String> parameters = new HashMap<String, String>();
//
+ parameters.put(TYPE, PORTLET_TYPE);
+
+ //
parameters.put(WINDOW_ID, windowId);
//
String type;
if (containerURL instanceof ActionURL)
{
- type = ACTION_LIFECYCLE;
+ type = ACTION_PHASE;
}
else if (containerURL instanceof RenderURL)
{
- type = RENDER_LIFECYCLE;
+ type = RENDER_PHASE;
}
else if (containerURL instanceof ResourceURL)
{
- type = RESOURCE_LIFECYCLE;
+ type = RESOURCE_PHASE;
}
else
{
throw new Error();
}
- parameters.put(LIFECYCLE_TYPE, type);
+ parameters.put(LIFECYCLE_PHASE, type);
//
String pageState = null;
@@ -236,20 +267,6 @@
}
//
- boolean first = true;
- for (Map.Entry<String, String> entry : parameters.entrySet())
- {
- String name = entry.getKey();
- String value = entry.getValue();
- buffer.append(first ? '?' : '&');
- buffer.append(name, FastURLEncoder.getUTF8Instance());
- buffer.append('=');
- buffer.append(value, FastURLEncoder.getUTF8Instance());
- first = false;
- }
-
- //
- String url = buffer.asString();
- return clientResp.encodeURL(url);
+ return renderURL(parameters, wantSecure, wantAuthenticated, relative);
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-07 18:31:21 UTC (rev 9838)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/TestPortletInvocationContext.java 2008-02-07 19:11:18 UTC (rev 9839)
@@ -76,7 +76,7 @@
this.clientResponse = clientResponse;
this.windowId = windowId;
this.pageState = pageState;
- this.urlRenderer = new PortletURLRenderer(stateContext, pageState, windowId, clientRequest, clientResponse);
+ this.urlRenderer = new PortletURLRenderer(stateContext, pageState, clientRequest, clientResponse);
//
addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(clientRequest));
@@ -98,6 +98,6 @@
public String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
{
- return urlRenderer.renderURL(containerURL, wantSecure, wantAuthenticated, relative);
+ return urlRenderer.renderURL(windowId, containerURL, wantSecure, wantAuthenticated, relative);
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 18:31:21 UTC (rev 9838)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 19:11:18 UTC (rev 9839)
@@ -42,6 +42,7 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.controller.PortletController;
+import org.jboss.portal.portlet.controller.request.PortletActionRequest;
import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
@@ -154,7 +155,30 @@
if (controllerResponse instanceof PageUpdateResponse)
{
PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
- pageState = pageUpdate.getPageState();
+
+ // We perform a send redirect on actions
+ if (context.getRequest() instanceof PortletActionRequest)
+ {
+ //
+ PortletURLRenderer renderer = new PortletURLRenderer(
+ (StateControllerContextImpl)context.getStateControllerContext(),
+ pageState,
+ context.getClientRequest(),
+ context.getClientResponse());
+
+ //
+ String url = renderer.renderURL(null, null, true);
+
+ //
+ resp.sendRedirect(url);
+
+ //
+ return;
+ }
+ else
+ {
+ pageState = pageUpdate.getPageState();
+ }
}
else if (controllerResponse instanceof ResourceResponse)
{
@@ -218,6 +242,10 @@
// todo
}
}
+ else
+ {
+ pageState = context.getPageState();
+ }
//
Page page = context.getPage();
@@ -344,7 +372,6 @@
PortletURLRenderer renderer = new PortletURLRenderer(
(StateControllerContextImpl)context.getStateControllerContext(),
pageState,
- windowId,
context.getClientRequest(),
context.getClientResponse());
@@ -372,7 +399,7 @@
};
//
- String renderedURL = renderer.renderURL(url, null, null, true);
+ String renderedURL = renderer.renderURL(windowId, url, null, null, true);
writer.write(renderedURL);
writer.flush();
}
16 years, 4 months
JBoss Portal SVN: r9838 - in modules/portlet/trunk/test/src: main/java/org/jboss/portal/portlet/controller/impl/state and 6 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 13:31:21 -0500 (Thu, 07 Feb 2008)
New Revision: 9838
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
Log:
simplify a bit, make PageNavigationalState use a boolean instead of having a *Mutable* subclass
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/PortletRequestHandler.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -88,11 +88,11 @@
PageNavigationalState pageState = portletRequest.getPageState();
if (pageState == null)
{
- pageState = stateContext.createPageState();
+ pageState = stateContext.createPageState(true);
}
else
{
- pageState = stateContext.clonePageState(pageState);
+ pageState = stateContext.clonePageState(pageState, true);
}
//
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/MutablePageNavigationalState.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -1,102 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.controller.impl.state;
-
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.info.NavigationInfo;
-import org.jboss.portal.portlet.info.ParameterInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-
-import javax.xml.namespace.QName;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-class MutablePageNavigationalState extends PageNavigationalStateImpl
-{
-
- MutablePageNavigationalState(StateControllerContextImpl context)
- {
- super(context);
- }
-
- public MutablePageNavigationalState(PageNavigationalStateImpl original)
- {
- super(original);
- }
-
- public void setWindowNavigationalState(String windowId, WindowNavigationalState windowState)
- {
- windows.put(windowId, windowState);
- }
-
- public void setPublicNavigationalState(String windowId, Map<String, String[]> update)
- {
- try
- {
- PortletInfo info = context.portletControllerContext.getPortletInfo(windowId);
-
- NavigationInfo navigationInfo = info.getNavigation();
- for (Map.Entry<String, String[]> entry : update.entrySet())
- {
- String id = entry.getKey();
-
- //
- ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
-
- //
- if (parameterInfo != null)
- {
- QName name = parameterInfo.getName();
- String[] value = entry.getValue();
- if (value.length > 0)
- {
- setPublicNavigationalState(name, value);
- }
- else
- {
- removePublicNavigationalState(name);
- }
- }
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
-
- public void setPublicNavigationalState(QName name, String[] value)
- {
- // We clone the value in order to keep the state not mutated by a side effect
- page.put(name, value.clone());
- }
-
- public void removePublicNavigationalState(QName name)
- {
- page.remove(name);
- }
-}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -28,6 +28,7 @@
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.info.ParameterInfo;
import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.NavigationInfo;
import javax.xml.namespace.QName;
import java.io.Serializable;
@@ -51,18 +52,23 @@
/** . */
protected final Map<QName, String[]> page;
- public PageNavigationalStateImpl(StateControllerContextImpl context)
+ /** . */
+ private final boolean modifiable;
+
+ PageNavigationalStateImpl(StateControllerContextImpl context, boolean modifiable)
{
this.context = context;
this.windows = new HashMap<String, WindowNavigationalState>();
this.page = new HashMap<QName, String[]>();
+ this.modifiable = modifiable;
}
- public PageNavigationalStateImpl(PageNavigationalStateImpl original)
+ public PageNavigationalStateImpl(PageNavigationalStateImpl original, boolean modifiable)
{
this.context = original.context;
this.windows = new HashMap<String, WindowNavigationalState>(original.windows);
this.page = new HashMap<QName, String[]>(original.page);
+ this.modifiable = modifiable;
}
public Set<String> getWindowIds()
@@ -115,24 +121,78 @@
return page.get(name).clone();
}
- public void setWindowNavigationalState(String windowId, WindowNavigationalState windowState) throws UnsupportedOperationException
+ public void setWindowNavigationalState(String windowId, WindowNavigationalState windowState)
{
- throw new UnsupportedOperationException();
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ //
+ windows.put(windowId, windowState);
}
public void setPublicNavigationalState(String windowId, Map<String, String[]> update)
{
- throw new UnsupportedOperationException();
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ //
+ try
+ {
+ PortletInfo info = context.portletControllerContext.getPortletInfo(windowId);
+
+ NavigationInfo navigationInfo = info.getNavigation();
+ for (Map.Entry<String, String[]> entry : update.entrySet())
+ {
+ String id = entry.getKey();
+
+ //
+ ParameterInfo parameterInfo = navigationInfo.getPublicParameter(id);
+
+ //
+ if (parameterInfo != null)
+ {
+ QName name = parameterInfo.getName();
+ String[] value = entry.getValue();
+ if (value.length > 0)
+ {
+ setPublicNavigationalState(name, value);
+ }
+ else
+ {
+ removePublicNavigationalState(name);
+ }
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
}
- public void setPublicNavigationalState(QName name, String[] value) throws UnsupportedOperationException
+ public void setPublicNavigationalState(QName name, String[] value)
{
- throw new UnsupportedOperationException();
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ // We clone the value in order to keep the state not mutated by a side effect
+ page.put(name, value.clone());
}
- public void removePublicNavigationalState(QName name) throws UnsupportedOperationException
+ public void removePublicNavigationalState(QName name)
{
- throw new UnsupportedOperationException();
+ if (!modifiable)
+ {
+ throw new IllegalStateException("The page navigational state is not modifiable");
+ }
+
+ //
+ page.remove(name);
}
-
}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -92,14 +92,14 @@
this.portletControllerContext = portletControllerContext;
}
- public PageNavigationalState clonePageState(PageNavigationalState pageState)
+ public PageNavigationalState clonePageState(PageNavigationalState pageState, boolean modifiable)
{
- return new MutablePageNavigationalState((PageNavigationalStateImpl)pageState);
+ return new PageNavigationalStateImpl((PageNavigationalStateImpl)pageState, modifiable);
}
- public PageNavigationalState createPageState()
+ public PageNavigationalState createPageState(boolean modifiable)
{
- return new MutablePageNavigationalState(this);
+ return new PageNavigationalStateImpl(this, modifiable);
}
public byte[] serialize(PageNavigationalState object)
@@ -192,14 +192,14 @@
}
}
- public PageNavigationalState unserialize(byte[] bytes)
+ public PageNavigationalState unserialize(byte[] bytes, boolean modifiable)
{
try
{
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
GZIPInputStream zis = new GZIPInputStream(bais);
DataInputStream in = new DataInputStream(zis);
- PageNavigationalStateImpl pageState = new MutablePageNavigationalState(this);
+ PageNavigationalStateImpl pageState = new PageNavigationalStateImpl(this, modifiable);
//
int size = in.readInt();
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -29,7 +29,9 @@
import java.util.Set;
/**
- * Defines the page navigational state that the controller needs.
+ * Defines the page navigational state view that the controller needs to operate on. Its name begins with page
+ * however it does not mandate that the represented context to be a page. I.E it could represent a set
+ * of physical pages or something else.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -37,6 +39,11 @@
public interface PageNavigationalState
{
+ /**
+ * Returns the window ids referenced.
+ *
+ * @return a set of window id
+ */
Set<String> getWindowIds();
/**
@@ -44,17 +51,19 @@
*
* @param windowId the window
* @return the window navigational state
+ * @throws IllegalArgumentException if an argument is not valid
*/
- WindowNavigationalState getWindowNavigationalState(String windowId);
+ WindowNavigationalState getWindowNavigationalState(String windowId) throws IllegalArgumentException;
/**
* Update the navigational state of a window.
*
* @param windowId the window id
* @param windowState the window state
- * @throws UnsupportedOperationException if the page state is read only
+ * @throws IllegalArgumentException if an argument is not valid
+ * @throws IllegalStateException if the page state is read only
*/
- void setWindowNavigationalState(String windowId, WindowNavigationalState windowState) throws UnsupportedOperationException;
+ void setWindowNavigationalState(String windowId, WindowNavigationalState windowState) throws IllegalArgumentException, IllegalStateException;
/**
* Obtain the public navigational state of a window. The interpretation of what should be retrieved is left up to the
@@ -63,8 +72,9 @@
*
* @param windowId the window id
* @return the public navigational state
+ * @throws IllegalArgumentException if an argument is not valid
*/
- ParameterMap getPublicNavigationalState(String windowId);
+ ParameterMap getPublicNavigationalState(String windowId) throws IllegalArgumentException;
/**
* Update the public navigational state of a window. The interpretation of what should be updated is left up to the
@@ -75,13 +85,36 @@
*
* @param windowId the window id
* @param update the updates
- * @throws UnsupportedOperationException if the page state is read only
+ * @throws IllegalArgumentException if an argument is not valid
+ * @throws IllegalStateException if the page state is read only
*/
- void setPublicNavigationalState(String windowId, Map<String, String[]> update) throws UnsupportedOperationException;
+ void setPublicNavigationalState(String windowId, Map<String, String[]> update) throws IllegalArgumentException, IllegalStateException;
- String[] getPublicNavigationalState(QName name);
+ /**
+ * Returns a public navigational state entry or null if it is not found.
+ *
+ * @param name the name
+ * @return the entry value
+ * @throws IllegalArgumentException if an argument is not valid
+ */
+ String[] getPublicNavigationalState(QName name) throws IllegalArgumentException;
- void setPublicNavigationalState(QName name, String[] value);
+ /**
+ * Sets a public navigational state entry.
+ *
+ * @param name the name
+ * @param value the new value
+ * @throws IllegalArgumentException if an argument is not valid
+ * @throws IllegalStateException if the page state is read only
+ */
+ void setPublicNavigationalState(QName name, String[] value) throws IllegalArgumentException, IllegalStateException;
- void removePublicNavigationalState(QName name);
+ /**
+ * Removes a public navigational state entry.
+ *
+ * @param name the name
+ * @throws IllegalArgumentException if an argument is not valid
+ * @throws IllegalStateException if the page state is read only
+ */
+ void removePublicNavigationalState(QName name) throws IllegalArgumentException, IllegalStateException;
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/StateControllerContext.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -35,15 +35,17 @@
* Clone an existing page state object.
*
* @param pageState the page state to clone
+ * @param modifiable set the modifiable status
* @return the page state clone
*/
- PageNavigationalState clonePageState(PageNavigationalState pageState);
+ PageNavigationalState clonePageState(PageNavigationalState pageState, boolean modifiable);
/**
* Create a new page state object.
*
+ * @param modifiable set the modifiable status
* @return the new page state
*/
- PageNavigationalState createPageState();
+ PageNavigationalState createPageState(boolean modifiable);
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/PortalServlet.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -87,7 +87,7 @@
}
else
{
- PageRenderer renderer = new PageRenderer(new ResponseProperties(), context.getStateControllerContext().createPageState());
+ PageRenderer renderer = new PageRenderer(new ResponseProperties(), context.getStateControllerContext().createPageState(false));
//
renderer.render(context);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -133,7 +133,7 @@
if (context != null)
{
byte[] bytes = Base64.decode(context, true);
- pageState = tmp.unserialize(bytes);
+ pageState = tmp.unserialize(bytes, false);
}
//
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -223,7 +223,7 @@
Page page = context.getPage();
if (pageState == null)
{
- pageState = context.getStateControllerContext().createPageState();
+ pageState = context.getStateControllerContext().createPageState(false);
}
// Look if we need to handle maxmized rendering
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/SimplePortalServlet.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -87,7 +87,7 @@
}
else
{
- PageRenderer renderer = new PageRenderer(new ResponseProperties(), context.getStateControllerContext().createPageState());
+ PageRenderer renderer = new PageRenderer(new ResponseProperties(), context.getStateControllerContext().createPageState(false));
//
renderer.render(context);
Modified: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java 2008-02-07 18:01:50 UTC (rev 9837)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java 2008-02-07 18:31:21 UTC (rev 9838)
@@ -62,7 +62,7 @@
@Test
public void testMarshalling1()
{
- PageNavigationalState pageNS = cc.createPageState();
+ PageNavigationalState pageNS = cc.createPageState(true);
assertMarshallable(pageNS);
}
@@ -89,7 +89,7 @@
private void test(StateString portletNavigationalState, Mode mode, WindowState windowState)
{
- PageNavigationalState pageNS = cc.createPageState();
+ PageNavigationalState pageNS = cc.createPageState(true);
pageNS.setWindowNavigationalState("foo", new WindowNavigationalState(portletNavigationalState, mode, windowState));
assertMarshallable(pageNS);
}
@@ -97,7 +97,7 @@
private void assertMarshallable(PageNavigationalState pageNS)
{
byte[] bytes = cc.serialize(pageNS);
- PageNavigationalState expectedPageNS = cc.unserialize(bytes);
+ PageNavigationalState expectedPageNS = cc.unserialize(bytes, true);
assertEquals(expectedPageNS.getWindowIds(), pageNS.getWindowIds());
for (String windowId : expectedPageNS.getWindowIds())
{
16 years, 4 months
JBoss Portal SVN: r9837 - in modules/portlet/trunk: test/src/main/java/org/jboss/portal/portlet/controller/impl/state and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 13:01:50 -0500 (Thu, 07 Feb 2008)
New Revision: 9837
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
Log:
- reuse Map<String,String[]> serialization in order to reduce now the public nav state size in the URL
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-02-07 17:37:56 UTC (rev 9836)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-02-07 18:01:50 UTC (rev 9837)
@@ -24,6 +24,7 @@
import org.jboss.portal.common.util.Base64;
import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.common.io.Serialization;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -151,19 +152,7 @@
private ParametersStateString(DataInputStream in) throws IOException
{
- int size = in.readInt();
- Map<String, String[]> tmp = new HashMap<String, String[]>(size);
- while (size-- > 0)
- {
- String name = in.readUTF();
- int length = in.readInt();
- String[] values = new String[length];
- for (int i = 0;i < length;i++)
- {
- values[i] = in.readUTF();
- }
- tmp.put(name, values);
- }
+ Map<String, String[]> tmp = Serialization.PARAMETER_MAP.unserialize(in);
//
parameters = ParameterMap.wrap(tmp);
@@ -389,19 +378,7 @@
else
{
out.writeByte(1);
- out.writeInt(parameters.size());
- for (Map.Entry entry : parameters.entrySet())
- {
- String name = (String)entry.getKey();
- out.writeUTF(name);
- String[] values = (String[])entry.getValue();
- int length = values.length;
- out.writeInt(length);
- for (String value : values)
- {
- out.writeUTF(value);
- }
- }
+ Serialization.PARAMETER_MAP.serialize(parameters, out);
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-07 17:37:56 UTC (rev 9836)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-07 18:01:50 UTC (rev 9837)
@@ -32,6 +32,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.common.io.UndeclaredIOException;
+import javax.xml.namespace.QName;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -109,6 +110,8 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream zos = new GZIPOutputStream(baos);
DataOutputStream out = new DataOutputStream(zos);
+
+ //
out.writeInt(pageState.windows.size());
for (Map.Entry<String, WindowNavigationalState> entry : pageState.windows.entrySet())
{
@@ -161,6 +164,25 @@
out.writeUTF(windowNS.getMode().toString());
}
}
+
+ //
+ Map<QName, String[]> publicNS = pageState.page;
+ out.writeInt(publicNS.size());
+ for (Map.Entry<QName, String[]> entry : publicNS.entrySet())
+ {
+ QName name = entry.getKey();
+ out.writeUTF(name.getNamespaceURI());
+ out.writeUTF(name.getLocalPart());
+ String[] values = entry.getValue();
+ int length = values.length;
+ out.writeInt(length);
+ for (String value : values)
+ {
+ out.writeUTF(value);
+ }
+ }
+
+ //
out.close();
return baos.toByteArray();
}
@@ -178,6 +200,8 @@
GZIPInputStream zis = new GZIPInputStream(bais);
DataInputStream in = new DataInputStream(zis);
PageNavigationalStateImpl pageState = new MutablePageNavigationalState(this);
+
+ //
int size = in.readInt();
while (size-- > 0)
{
@@ -213,10 +237,26 @@
mode = codeToMode.get(modeStateHeader);
}
WindowNavigationalState windowNS = new WindowNavigationalState(portletNS, mode, windowState);
- pageState.setWindowNavigationalState(windowId, windowNS);
+ pageState.windows.put(windowId, windowNS);
}
//
+ size = in.readInt();
+ while (size-- > 0)
+ {
+ String namespaceURI = in.readUTF();
+ String localName = in.readUTF();
+ QName name = new QName(namespaceURI, localName);
+ int length = in.readInt();
+ String[] values = new String[length];
+ for (int i = 0;i < length;i++)
+ {
+ values[i] = in.readUTF();
+ }
+ pageState.page.put(name, values);
+ }
+
+ //
return pageState;
}
catch (IOException e)
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 17:37:56 UTC (rev 9836)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 18:01:50 UTC (rev 9837)
@@ -26,10 +26,10 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.Serialization;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.ParameterMap;
-import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.Base64;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.Portlet;
@@ -234,7 +234,8 @@
}
else
{
- Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES)));
+ byte[] bytes = Base64.decode(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES), true);
+ Map<String, String[]> publicNavigationalStateChanges = IOTools.unserialize(Serialization.PARAMETER_MAP, bytes);
//
request = new PortletRenderRequest(
@@ -352,4 +353,5 @@
{
return new TestPortletInvocationContext(stateControllerContext, req, resp, windowId, pageState, MARKUP_INFO);
}
+
}
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 17:37:56 UTC (rev 9836)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 18:01:50 UTC (rev 9837)
@@ -24,6 +24,7 @@
package org.jboss.portal.portlet.test.controller;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.io.Serialization;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
@@ -175,18 +176,10 @@
RenderURL renderURL = (RenderURL)containerURL;
//
- try
- {
- Map<String, String[]> changes = renderURL.getPublicNavigationalStateChanges();
- HashMap<String, String[]> serialiableChanges = new HashMap<String, String[]>(changes);
- byte[] bytes = IOTools.serialize(serialiableChanges);
- String ns = Tools.toHexString(bytes);
- parameters.put(PUBLIC_NAVIGATIONAL_STATE_CHANGES, ns);
- }
- catch (IOException e)
- {
- throw new Error(e);
- }
+ Map<String, String[]> changes = renderURL.getPublicNavigationalStateChanges();
+ byte[] bytes = IOTools.serialize(Serialization.PARAMETER_MAP, changes);
+ String ns = Base64.encodeBytes(bytes, true);
+ parameters.put(PUBLIC_NAVIGATIONAL_STATE_CHANGES, ns);
//
StateString navigationalState = renderURL.getNavigationalState();
16 years, 4 months
JBoss Portal SVN: r9836 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/io and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 12:37:56 -0500 (Thu, 07 Feb 2008)
New Revision: 9836
Added:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/Serialization.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java
Log:
added concept of Serialization for known types (such as the recurrent Map<String,String[]>) with a compact format
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java 2008-02-07 16:47:40 UTC (rev 9835)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/IOTools.java 2008-02-07 17:37:56 UTC (rev 9836)
@@ -40,6 +40,8 @@
import java.io.ObjectInputStream;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
+import java.io.DataOutputStream;
+import java.util.Map;
/**
* IO tools.
@@ -384,6 +386,49 @@
return (Serializable)ois.readObject();
}
+ public static <T> byte[] serialize(Serialization<T> serialization, T t)
+ {
+ if (serialization == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (t == null)
+ {
+ throw new IllegalArgumentException("No null object to serialize");
+ }
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ serialization.serialize(t, baos);
+ return baos.toByteArray();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public static <T> T unserialize(Serialization<T> serialization, byte[] bytes)
+ {
+ if (serialization == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("No null bytes to unserialize");
+ }
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ return serialization.unserialize(bais);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
/**
* Check that the provided input stream is buffered. If the argument is already an instance of <code>BufferedInputStream</code>
* no operation will be performed, otherwise a instance of <code>BufferedInputStream</code> will be created and returned.
Added: modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/Serialization.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/Serialization.java (rev 0)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/Serialization.java 2008-02-07 17:37:56 UTC (rev 9836)
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.common.io;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.DataInputStream;
+import java.io.OutputStream;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface Serialization<T>
+{
+
+ Serialization<Map<String, String[]>> PARAMETER_MAP = new Serialization<Map<String, String[]>>()
+ {
+ public void serialize(Map<String, String[]> map, OutputStream out) throws IOException, IllegalArgumentException
+ {
+ if (map == null)
+ {
+ throw new IllegalArgumentException("No null map allowed");
+ }
+
+ //
+ DataOutputStream data = out instanceof DataOutputStream ? (DataOutputStream)out : new DataOutputStream(out);
+
+ //
+ data.writeInt(map.size());
+
+ //
+ for (Map.Entry entry : map.entrySet())
+ {
+ String name = (String)entry.getKey();
+ data.writeUTF(name);
+
+ //
+ String[] values = (String[])entry.getValue();
+ if (values == null)
+ {
+ throw new IllegalArgumentException("No null values are allowed in the map");
+ }
+
+ //
+ int length = values.length;
+ data.writeInt(length);
+
+ //
+ for (String value : values)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null value in the String[] are allowed in the map");
+ }
+ data.writeUTF(value);
+ }
+ }
+
+ //
+ data.flush();
+ }
+
+ public Map<String, String[]> unserialize(InputStream in) throws IOException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input stream");
+ }
+
+ //
+ DataInputStream data = in instanceof DataInputStream ? (DataInputStream)in : new DataInputStream(in);
+
+ //
+ int size = data.readInt();
+ Map<String, String[]> tmp = new HashMap<String, String[]>(size);
+ while (size-- > 0)
+ {
+ String name = data.readUTF();
+ int length = data.readInt();
+ String[] values = new String[length];
+ for (int i = 0;i < length;i++)
+ {
+ values[i] = data.readUTF();
+ }
+ tmp.put(name, values);
+ }
+
+ //
+ return tmp;
+ }
+ };
+
+ public abstract void serialize(T t, OutputStream out) throws IOException, IllegalArgumentException;
+
+ public abstract T unserialize(InputStream in) throws IOException, IllegalArgumentException;
+
+}
Added: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java (rev 0)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java 2008-02-07 17:37:56 UTC (rev 9836)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.common.io;
+
+import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.util.MapBuilder;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SerializationTestCase extends TestCase
+{
+
+ public void testParameterMapSerialization()
+ {
+ check(new HashMap<String, String[]>());
+ check(MapBuilder.hashMap("foo", new String[]{"foo_value"}).get());
+ check(MapBuilder.hashMap("foo", new String[]{"foo_value1","foo_value2"}).get());
+ check(MapBuilder.hashMap("foo", new String[]{"foo_value1","foo_value2"}).put("bar", new String[]{"bar_value"}).get());
+ }
+
+ private void check(Map<String, String[]> map)
+ {
+ byte[] bytes = IOTools.serialize(Serialization.PARAMETER_MAP, map);
+ Map<String, String[]> copy = IOTools.unserialize(Serialization.PARAMETER_MAP, bytes);
+ assertEquals(map.keySet(), copy.keySet());
+ for (Map.Entry<String, String[]> entry : map.entrySet())
+ {
+ String[] values = map.get(entry.getKey());
+ String[] valuesCopy = copy.get(entry.getKey());
+ ExtendedAssert.assertEquals(values, valuesCopy);
+ }
+ }
+}
16 years, 4 months
JBoss Portal SVN: r9835 - in modules/portlet/trunk: portlet/src/test/java/org/jboss/portal/test/portlet and 10 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 11:47:40 -0500 (Thu, 07 Feb 2008)
New Revision: 9835
Added:
modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/StateStringTestCase.java
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/
modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/OpaqueStateString.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/StateString.java
modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
modules/portlet/trunk/test/pom.xml
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml
Log:
- rewrote PageNavigationalState marshalling to be optimized in size
- added test cases for PageNavigationalState marshalling
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/OpaqueStateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/OpaqueStateString.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/OpaqueStateString.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -22,6 +22,9 @@
******************************************************************************/
package org.jboss.portal.portlet;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
/**
* An opaque implementation of the navigational state.
*
@@ -31,6 +34,7 @@
public class OpaqueStateString extends StateString
{
+ /** . */
private String value;
public OpaqueStateString(String value)
@@ -47,6 +51,12 @@
return value;
}
+ public void writeTo(DataOutputStream out) throws IOException
+ {
+ out.writeByte(2);
+ out.writeUTF(value);
+ }
+
public int hashCode()
{
return value.hashCode();
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/ParametersStateString.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -31,6 +31,9 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.io.DataOutputStream;
+import java.io.InputStream;
+import java.io.DataInputStream;
import java.util.HashMap;
import java.util.Map;
@@ -63,6 +66,36 @@
}
/**
+ * Factory method that will create the most appropriate form from the byte representation.
+ *
+ * @param in the inputstream to read from
+ * @return a new state string
+ * @throws IOException any IOException
+ */
+ public static StateString create(DataInputStream in) throws IOException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ byte b = in.readByte();
+ switch (b)
+ {
+ case 0:
+ return new ParametersStateString();
+ case 1:
+ return new ParametersStateString(in);
+ case 2:
+ return new OpaqueStateString(in.readUTF());
+ }
+
+ //
+ throw new IllegalArgumentException("Wrong format unrecognized header " + b);
+ }
+
+ /**
* Factory method that will create the most appropriate form from the string representation.
*
* @param opaqueValue the opaque value
@@ -116,16 +149,34 @@
/** The underlying map that does not have a copy read/write access mode. */
private ParameterMap parameters;
- private ParametersStateString(String opaqueValue)
+ private ParametersStateString(DataInputStream in) throws IOException
{
- if (opaqueValue == null)
+ int size = in.readInt();
+ Map<String, String[]> tmp = new HashMap<String, String[]>(size);
+ while (size-- > 0)
{
- throw new IllegalArgumentException("No navigational state provided");
+ String name = in.readUTF();
+ int length = in.readInt();
+ String[] values = new String[length];
+ for (int i = 0;i < length;i++)
+ {
+ values[i] = in.readUTF();
+ }
+ tmp.put(name, values);
}
+
+ //
+ parameters = ParameterMap.wrap(tmp);
+ }
+
+ private ParametersStateString(String opaqueValue)
+ {
if (!opaqueValue.startsWith(JBPNS_PREFIX))
{
throw new IllegalArgumentException("Bad format");
}
+
+ //
opaqueValue = opaqueValue.substring(JBPNS_PREFIX.length());
if (opaqueValue.length() > 0)
{
@@ -166,7 +217,7 @@
}
catch (Exception e)
{
- throw new RuntimeException(e);
+ throw new Error(e);
}
}
else
@@ -329,6 +380,31 @@
}
}
+ public void writeTo(DataOutputStream out) throws IOException
+ {
+ if (parameters.isEmpty())
+ {
+ out.writeByte(0);
+ }
+ else
+ {
+ out.writeByte(1);
+ out.writeInt(parameters.size());
+ for (Map.Entry entry : parameters.entrySet())
+ {
+ String name = (String)entry.getKey();
+ out.writeUTF(name);
+ String[] values = (String[])entry.getValue();
+ int length = values.length;
+ out.writeInt(length);
+ for (String value : values)
+ {
+ out.writeUTF(value);
+ }
+ }
+ }
+ }
+
public String toString()
{
return "StateString[" + parameters + "]";
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/StateString.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/StateString.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/StateString.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -23,6 +23,10 @@
package org.jboss.portal.portlet;
import java.io.Serializable;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.util.zip.GZIPOutputStream;
/**
* Encapsulate state as a string.
@@ -39,13 +43,6 @@
*/
public abstract String getStringValue();
- public static StateString createFrom(String opaqueValue)
- {
- if (opaqueValue == null)
- {
- return null;
- }
- return new OpaqueStateString(opaqueValue);
- }
+ public abstract void writeTo(DataOutputStream out) throws IOException;
}
Added: modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/StateStringTestCase.java
===================================================================
--- modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/StateStringTestCase.java (rev 0)
+++ modules/portlet/trunk/portlet/src/test/java/org/jboss/portal/test/portlet/StateStringTestCase.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.OpaqueStateString;
+import org.jboss.portal.common.util.MapBuilder;
+import static org.jboss.unit.api.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.util.zip.GZIPOutputStream;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@Test
+public class StateStringTestCase
+{
+
+ @Test
+ public void testMarshalling() throws IOException
+ {
+ check(new OpaqueStateString("blah"));
+ check(ParametersStateString.create());
+ check(MapBuilder.hashMap("foo", new String[]{"bar"}).get());
+ check(MapBuilder.hashMap("foo", new String[]{"foo_1"}).put("bar", new String[]{"bar_1", "bar_2"}).get());
+ }
+
+ private void check(Map<String, String[]> parameters) throws IOException
+ {
+ check(ParametersStateString.create(parameters));
+ }
+
+ private void check(StateString parameters) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream out = new DataOutputStream(baos);
+ parameters.writeTo(out);
+ out.close();
+ byte[] bytes = baos.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ DataInputStream in = new DataInputStream(bais);
+ StateString copy = ParametersStateString.create(in);
+ assertEquals(parameters, copy);
+ }
+}
Modified: modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/portlet/src/test/resources/local-jboss-unit.xml 2008-02-07 16:47:40 UTC (rev 9835)
@@ -34,5 +34,8 @@
<test>
<class name="org.jboss.portal.test.portlet.ContentBufferTestCase"/>
</test>
+ <test>
+ <class name="org.jboss.portal.test.portlet.StateStringTestCase"/>
+ </test>
</pojo>
</jboss-unit>
Modified: modules/portlet/trunk/test/pom.xml
===================================================================
--- modules/portlet/trunk/test/pom.xml 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/pom.xml 2008-02-07 16:47:40 UTC (rev 9835)
@@ -206,6 +206,11 @@
</execution>
</executions>
<configuration>
+ <!--<jpda>false</jpda>-->
+ <!--<jpdaPort>9000</jpdaPort>-->
+ <!--<jpdaSuspend>true</jpdaSuspend>-->
+ <!--<failOnError>false</failOnError>-->
+ <!--<assertions>true</assertions>-->
<testsuites>
<testsuite>
<config>test/local-jboss-unit.xml</config>
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -33,6 +33,7 @@
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -42,7 +43,7 @@
{
/** We don't save it. */
- protected transient StateControllerContextImpl context;
+ protected final StateControllerContextImpl context;
/** . */
protected final Map<String, WindowNavigationalState> windows;
@@ -64,6 +65,11 @@
this.page = new HashMap<QName, String[]>(original.page);
}
+ public Set<String> getWindowIds()
+ {
+ return windows.keySet();
+ }
+
public WindowNavigationalState getWindowNavigationalState(String windowId)
{
return windows.get(windowId);
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/StateControllerContextImpl.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -25,14 +25,22 @@
import org.jboss.portal.portlet.controller.PortletControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.io.UndeclaredIOException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.DataOutputStream;
+import java.io.DataInputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -42,10 +50,44 @@
{
/** . */
+ private static final Map<WindowState, Integer> windowStateToCode = new HashMap<WindowState, Integer>();
+
+ /** . */
+ private static final Map<Mode, Integer> modeToCode = new HashMap<Mode, Integer>();
+
+ /** . */
+ private static final Map<Integer, WindowState> codeToWindowState = new HashMap<Integer, WindowState>();
+
+ /** . */
+ private static final Map<Integer, Mode> codeToMode = new HashMap<Integer, Mode>();
+
+ static
+ {
+ windowStateToCode.put(WindowState.NORMAL, 1);
+ windowStateToCode.put(WindowState.MINIMIZED, 2);
+ windowStateToCode.put(WindowState.MAXIMIZED, 3);
+ codeToWindowState.put(1, WindowState.NORMAL);
+ codeToWindowState.put(2, WindowState.MINIMIZED);
+ codeToWindowState.put(3, WindowState.MAXIMIZED);
+ modeToCode.put(Mode.VIEW, 1);
+ modeToCode.put(Mode.EDIT, 2);
+ modeToCode.put(Mode.HELP, 3);
+ codeToMode.put(1, Mode.VIEW);
+ codeToMode.put(2, Mode.EDIT);
+ codeToMode.put(3, Mode.HELP);
+ }
+
+ /** . */
protected final PortletControllerContext portletControllerContext;
public StateControllerContextImpl(PortletControllerContext portletControllerContext)
{
+ if (portletControllerContext == null)
+ {
+ throw new IllegalArgumentException("No portlet controller context available");
+ }
+
+ //
this.portletControllerContext = portletControllerContext;
}
@@ -59,23 +101,127 @@
return new MutablePageNavigationalState(this);
}
- public byte[] serialize(PageNavigationalState object) throws IOException
+ public byte[] serialize(PageNavigationalState object)
{
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream zos = new GZIPOutputStream(baos);
- ObjectOutputStream oos = new ObjectOutputStream(zos);
- oos.writeObject(object);
- oos.close();
- return baos.toByteArray();
+ try
+ {
+ PageNavigationalStateImpl pageState = (PageNavigationalStateImpl)object;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream zos = new GZIPOutputStream(baos);
+ DataOutputStream out = new DataOutputStream(zos);
+ out.writeInt(pageState.windows.size());
+ for (Map.Entry<String, WindowNavigationalState> entry : pageState.windows.entrySet())
+ {
+ out.writeUTF(entry.getKey());
+ WindowNavigationalState windowNS = entry.getValue();
+ byte header = 0;
+ int decision = 0;
+ if (windowNS.getPortletNavigationalState() != null)
+ {
+ header |= 1;
+ decision |= 1;
+ }
+ if (windowNS.getWindowState() != null)
+ {
+ Integer value = windowStateToCode.get(windowNS.getWindowState());
+ if (value != null)
+ {
+ header |= value << 1;
+ }
+ else
+ {
+ header |= 4 << 1;
+ decision |= 2;
+ }
+ }
+ if (windowNS.getMode() != null)
+ {
+ Integer value = modeToCode.get(windowNS.getMode());
+ if (value != null)
+ {
+ header |= value << 4;
+ }
+ else
+ {
+ header |= 4 << 4;
+ decision |= 4;
+ }
+ }
+ out.writeByte(header);
+ if ((decision & 1) != 0)
+ {
+ windowNS.getPortletNavigationalState().writeTo(out);
+ }
+ if ((decision & 2) != 0)
+ {
+ out.writeUTF(windowNS.getWindowState().toString());
+ }
+ if ((decision & 4) != 0)
+ {
+ out.writeUTF(windowNS.getMode().toString());
+ }
+ }
+ out.close();
+ return baos.toByteArray();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
}
- public PageNavigationalState unserialize(byte[] bytes) throws IOException, ClassNotFoundException
+ public PageNavigationalState unserialize(byte[] bytes)
{
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- GZIPInputStream zis = new GZIPInputStream(bais);
- ObjectInputStream ois = new ObjectInputStream(zis);
- PageNavigationalStateImpl state = (PageNavigationalStateImpl)ois.readObject();
- state.context = this;
- return state;
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ GZIPInputStream zis = new GZIPInputStream(bais);
+ DataInputStream in = new DataInputStream(zis);
+ PageNavigationalStateImpl pageState = new MutablePageNavigationalState(this);
+ int size = in.readInt();
+ while (size-- > 0)
+ {
+ String windowId = in.readUTF();
+ byte header = in.readByte();
+ StateString portletNS = null;
+ if ((header & 1) != 0)
+ {
+ portletNS = ParametersStateString.create(in);
+ }
+ WindowState windowState = null;
+ int windowStateHeader = (header & (7 << 1)) >> 1;
+ switch (windowStateHeader)
+ {
+ case 0:
+ break;
+ case 4:
+ windowState = WindowState.create(in.readUTF());
+ break;
+ default:
+ windowState = codeToWindowState.get(windowStateHeader);
+ }
+ Mode mode = null;
+ int modeStateHeader = (header & (7 << (1 + 3))) >> (1 + 3);
+ switch (modeStateHeader)
+ {
+ case 0:
+ break;
+ case 4:
+ mode = Mode.create(in.readUTF());
+ break;
+ default:
+ mode = codeToMode.get(modeStateHeader);
+ }
+ WindowNavigationalState windowNS = new WindowNavigationalState(portletNS, mode, windowState);
+ pageState.setWindowNavigationalState(windowId, windowNS);
+ }
+
+ //
+ return pageState;
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -26,6 +26,7 @@
import javax.xml.namespace.QName;
import java.util.Map;
+import java.util.Set;
/**
* Defines the page navigational state that the controller needs.
@@ -36,6 +37,8 @@
public interface PageNavigationalState
{
+ Set<String> getWindowIds();
+
/**
* Returns the navigational state of a window or null if it does not exist.
*
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -30,6 +30,7 @@
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.ParameterMap;
import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.util.Base64;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -131,7 +132,7 @@
String context = req.getParameter(PAGE_STATE);
if (context != null)
{
- byte[] bytes = Tools.fromHexString(context);
+ byte[] bytes = Base64.decode(context, true);
pageState = tmp.unserialize(bytes);
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -27,6 +27,7 @@
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.util.Base64;
import org.jboss.portal.portlet.ActionURL;
import org.jboss.portal.portlet.ContainerURL;
import org.jboss.portal.portlet.PortletURL;
@@ -126,18 +127,11 @@
//
String pageState = null;
- try
+ if (pageNS != null)
{
- if (pageNS != null)
- {
- byte[] bytes = stateContext.serialize(pageNS);
- pageState = Tools.toHexString(bytes);
- }
+ byte[] bytes = stateContext.serialize(pageNS);
+ pageState = Base64.encodeBytes(bytes, true);
}
- catch (IOException e)
- {
- throw new Error(e); //
- }
//
if (containerURL instanceof PortletURL)
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletChunk.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletChunk.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletChunk.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -1,86 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test.jsp.response.portlet;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.portlet.test.jsp.response.Chunk;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PortletChunk extends Chunk
-{
-
- /** . */
- private final String portletName;
-
- /** . */
- private final String applicationName;
-
- /** . */
- private final Mode initialMode;
-
- /** . */
- private final Set<Mode> supportedModes;
-
- /** . */
- private final Set<WindowState> supportedWindowStates;
-
- public PortletChunk(String portletName, String applicationName, Mode initialMode, Set<Mode> supportedModes, Set<WindowState> supportedWindowStates)
- {
- this.portletName = portletName;
- this.applicationName = applicationName;
- this.initialMode = initialMode;
- this.supportedModes = supportedModes;
- this.supportedWindowStates = supportedWindowStates;
- }
-
- public String getPortletName()
- {
- return portletName;
- }
-
- public String getApplicationName()
- {
- return applicationName;
- }
-
- public Mode getInitialMode()
- {
- return initialMode;
- }
-
- public Set<Mode> getSupportedModes()
- {
- return supportedModes;
- }
-
- public Set<WindowState> getSupportedWindowStates()
- {
- return supportedWindowStates;
- }
-}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -1,38 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test.jsp.taglib;
-
-import org.jboss.portal.portlet.test.jsp.response.Chunk;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletMarkupChunk;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class MarkupTag extends SimpleChunkTagSupport
-{
- protected Chunk doChunkTag()
- {
- return new PortletMarkupChunk();
- }
-}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -1,38 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test.jsp.taglib;
-
-import org.jboss.portal.portlet.test.jsp.response.Chunk;
-import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletTitleChunk;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class TitleTag extends SimpleChunkTagSupport
-{
- protected Chunk doChunkTag()
- {
- return new StartPortletTitleChunk();
- }
-}
Added: modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java
===================================================================
--- modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java (rev 0)
+++ modules/portlet/trunk/test/src/test/java/org/jboss/portal/portlet/controller/StateControllerContextTestCase.java 2008-02-07 16:47:40 UTC (rev 9835)
@@ -0,0 +1,165 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.controller;
+
+import org.jboss.unit.api.pojo.annotations.Test;
+import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.StateControllerContext;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.common.NotYetImplemented;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import static org.jboss.unit.api.Assert.*;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.Cookie;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+@Test
+public class StateControllerContextTestCase
+{
+
+ /** . */
+ private StateControllerContextImpl cc = new StateControllerContextImpl(dummyContext);
+
+ @Test
+ public void testMarshalling1()
+ {
+ PageNavigationalState pageNS = cc.createPageState();
+ assertMarshallable(pageNS);
+ }
+
+ @Test
+ public void testMarshalling2()
+ {
+ ParametersStateString params = ParametersStateString.create();
+ params.setValue("foo", "bar");
+ test(null, null, null);
+ test(null, Mode.VIEW, null);
+ test(null, null, WindowState.NORMAL);
+ test(null, Mode.VIEW, WindowState.NORMAL);
+ test(null, Mode.create("foo"), null);
+ test(null, null, WindowState.create("bar"));
+ test(null, Mode.create("foo"), WindowState.create("bar"));
+ test(params, null, null);
+ test(params, Mode.VIEW, null);
+ test(params, null, WindowState.NORMAL);
+ test(params, Mode.VIEW, WindowState.NORMAL);
+ test(params, Mode.create("foo"), null);
+ test(params, null, WindowState.create("bar"));
+ test(params, Mode.create("foo"), WindowState.create("bar"));
+ }
+
+ private void test(StateString portletNavigationalState, Mode mode, WindowState windowState)
+ {
+ PageNavigationalState pageNS = cc.createPageState();
+ pageNS.setWindowNavigationalState("foo", new WindowNavigationalState(portletNavigationalState, mode, windowState));
+ assertMarshallable(pageNS);
+ }
+
+ private void assertMarshallable(PageNavigationalState pageNS)
+ {
+ byte[] bytes = cc.serialize(pageNS);
+ PageNavigationalState expectedPageNS = cc.unserialize(bytes);
+ assertEquals(expectedPageNS.getWindowIds(), pageNS.getWindowIds());
+ for (String windowId : expectedPageNS.getWindowIds())
+ {
+ WindowNavigationalState windowNS = expectedPageNS.getWindowNavigationalState(windowId);
+ WindowNavigationalState expectedWindowNS = pageNS.getWindowNavigationalState(windowId);
+ assertEquals(windowNS.getPortletNavigationalState(), expectedWindowNS.getPortletNavigationalState());
+ assertEquals(windowNS.getMode(), expectedWindowNS.getMode());
+ assertEquals(windowNS.getWindowState(), expectedWindowNS.getWindowState());
+ }
+ }
+
+ private static final PortletControllerContext dummyContext = new PortletControllerContext()
+ {
+ public ServletContext getServletContext()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public PortletInfo getPortletInfo(String windowId) throws PortletInvokerException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageState)
+ {
+ throw new NotYetImplemented();
+ }
+
+ public PortletInvocationResponse invoke(String windowId, ActionInvocation actionInvocation) throws PortletInvokerException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public PortletInvocationResponse invoke(String windowId, List<Cookie> requestCookies, EventInvocation eventInvocation) throws PortletInvokerException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public PortletInvocationResponse invoke(String windowId, ResourceInvocation resourceInvocation) throws PortletInvokerException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public EventControllerContext getEventControllerContext()
+ {
+ throw new NotYetImplemented();
+ }
+
+ public StateControllerContext getStateControllerContext()
+ {
+ throw new NotYetImplemented();
+ }
+ };
+
+}
Modified: modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml 2008-02-07 12:22:13 UTC (rev 9834)
+++ modules/portlet/trunk/test/src/test/resources/test/local-jboss-unit.xml 2008-02-07 16:47:40 UTC (rev 9835)
@@ -83,5 +83,9 @@
<value>factory</value>
</parameter>
</test>
+ <test>
+ <class name="org.jboss.portal.portlet.controller.StateControllerContextTestCase">
+ </class>
+ </test>
</pojo>
</jboss-unit>
16 years, 4 months
JBoss Portal SVN: r9834 - modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 07:22:13 -0500 (Thu, 07 Feb 2008)
New Revision: 9834
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java
Log:
fix bug in maximize
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 12:04:09 UTC (rev 9833)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 12:22:13 UTC (rev 9834)
@@ -235,6 +235,7 @@
List<Chunk> chunks = new LinkedList<Chunk>();
int mode = 0;
int count = 0;
+ Map<StartPortletChunk, Window> windows = Collections.emptyMap();
for (Iterator<Chunk> i = page.getChunks().iterator();i.hasNext();)
{
Chunk chunk = i.next();
@@ -257,6 +258,7 @@
{
mode = 2;
chunks.add(startPortletChunk);
+ windows = Collections.singletonMap(startPortletChunk, window);
}
}
else if (chunk instanceof EndPageChunk)
@@ -284,7 +286,7 @@
}
// New page
- page = new Page(chunks, Collections.singletonMap(window.getId(), window));
+ page = new Page(chunks, windows);
}
}
@@ -296,7 +298,6 @@
OutputStreamWriter writer = new OutputStreamWriter(out);
//
- int count = 0;
String windowId = null;
StartPortletChunk startPortletChunk = null;
PortletInvocationResponse portletResponse = null;
@@ -317,7 +318,8 @@
else if (chunk instanceof StartPortletChunk)
{
startPortletChunk = (StartPortletChunk)chunk;
- windowId = "" + count++;
+ Window window = page.getWindow(startPortletChunk);
+ windowId = window.getId();
portletResponse = responses.get(windowId);
}
else if (chunk instanceof StartPortletTitleChunk)
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07 12:04:09 UTC (rev 9833)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07 12:22:13 UTC (rev 9834)
@@ -26,11 +26,12 @@
import org.jboss.portal.portlet.controller.PortletControllerContext;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletChunk;
import java.util.Map;
import java.util.HashMap;
+import java.util.Collection;
import java.util.List;
-import java.util.Collection;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -40,25 +41,37 @@
{
/** . */
- private Map<String, Window> windows;
+ private List<Chunk> chunks;
/** . */
- private List<Chunk> chunks;
+ private Map<StartPortletChunk, Window> windows;
- public Page(List<Chunk> chunks, Map<String, Window> windows)
+ public Page(List<Chunk> chunks, Map<StartPortletChunk, Window> windows)
{
this.chunks = chunks;
this.windows = windows;
}
- public List<Chunk> getChunks()
+ public Collection<Chunk> getChunks()
{
return chunks;
}
+ public Window getWindow(Chunk chunk)
+ {
+ return windows.get(chunk);
+ }
+
public Window getWindow(String windowId)
{
- return windows.get(windowId);
+ for (Window window : windows.values())
+ {
+ if (window.getId().equals(windowId))
+ {
+ return window;
+ }
+ }
+ return null;
}
public Collection<Window> getWindows()
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-07 12:04:09 UTC (rev 9833)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-07 12:22:13 UTC (rev 9834)
@@ -73,7 +73,7 @@
// Collect portlets to create the page
int counter = 0;
- Map<String, Window> windows = new LinkedHashMap<String, Window>();
+ Map<StartPortletChunk, Window> windows = new LinkedHashMap<StartPortletChunk, Window>();
for (Chunk chunk : buffer.getChunks())
{
if (chunk instanceof StartPortletChunk)
@@ -93,7 +93,7 @@
//
if (applicationName.equals(startPortletChunk.getApplicationName()) && portletName.equals(startPortletChunk.getPortletName()))
{
- windows.put(windowId, new Window(windowId, portlet));
+ windows.put(startPortletChunk, new Window(windowId, portlet));
}
}
}
@@ -105,8 +105,8 @@
}
//
-
+
//
this.page = new Page(buffer.getChunks(), windows);
this.invoker = invoker;
16 years, 4 months
JBoss Portal SVN: r9833 - in modules/portlet/trunk/test/src: main/java/org/jboss/portal/portlet/test/jsp/response and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 07:04:09 -0500 (Thu, 07 Feb 2008)
New Revision: 9833
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/EndPageChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/StartPageChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletChunk.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletTitleChunk.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
Log:
add support for maximized window in page
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 11:12:39 UTC (rev 9832)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -25,13 +25,15 @@
import org.jboss.portal.portlet.test.jsp.response.Chunk;
import org.jboss.portal.portlet.test.jsp.response.BytesChunk;
import org.jboss.portal.portlet.test.jsp.response.CharsChunk;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletMarkupChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletTitleChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletURLChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.EndPortletChunk;
import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
+import org.jboss.portal.portlet.test.jsp.response.StartPageChunk;
+import org.jboss.portal.portlet.test.jsp.response.EndPageChunk;
import org.jboss.portal.portlet.test.controller.PortletURLRenderer;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -65,6 +67,10 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Collections;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -220,6 +226,68 @@
pageState = context.getStateControllerContext().createPageState();
}
+ // Look if we need to handle maxmized rendering
+ for (Window window : page.getWindows())
+ {
+ WindowNavigationalState windowState = pageState.getWindowNavigationalState(window.getId());
+ if (windowState != null && WindowState.MAXIMIZED.equals(windowState.getWindowState()))
+ {
+ List<Chunk> chunks = new LinkedList<Chunk>();
+ int mode = 0;
+ int count = 0;
+ for (Iterator<Chunk> i = page.getChunks().iterator();i.hasNext();)
+ {
+ Chunk chunk = i.next();
+
+ switch (mode)
+ {
+ case 0:
+ if (chunk instanceof StartPageChunk)
+ {
+ mode = 1;
+ chunks.add(chunk);
+ }
+ break;
+ case 1:
+ if (chunk instanceof StartPortletChunk)
+ {
+ StartPortletChunk startPortletChunk = (StartPortletChunk)chunk;
+ String windowId = "" + count;
+ if (window.getId().equals(windowId))
+ {
+ mode = 2;
+ chunks.add(startPortletChunk);
+ }
+ }
+ else if (chunk instanceof EndPageChunk)
+ {
+ mode = 0;
+ chunks.add(chunk);
+ }
+ break;
+ case 2:
+ if (chunk instanceof EndPortletChunk)
+ {
+ mode = 1;
+ }
+
+ //
+ chunks.add(chunk);
+ break;
+ }
+
+ //
+ if (chunk instanceof EndPortletChunk)
+ {
+ count++;
+ }
+ }
+
+ // New page
+ page = new Page(chunks, Collections.singletonMap(window.getId(), window));
+ }
+ }
+
//
Map<String, PortletInvocationResponse> responses = page.render(context, pageState);
@@ -230,7 +298,7 @@
//
int count = 0;
String windowId = null;
- PortletChunk portletChunk = null;
+ StartPortletChunk startPortletChunk = null;
PortletInvocationResponse portletResponse = null;
for (Chunk chunk : page.getChunks())
{
@@ -246,9 +314,9 @@
writer.write(bytesChunk.getChars());
writer.flush();
}
- else if (chunk instanceof PortletChunk)
+ else if (chunk instanceof StartPortletChunk)
{
- portletChunk = (PortletChunk)chunk;
+ startPortletChunk = (StartPortletChunk)chunk;
windowId = "" + count++;
portletResponse = responses.get(windowId);
}
@@ -316,7 +384,7 @@
{
FragmentResponse fragment = (FragmentResponse)portletResponse;
WindowNavigationalState windowNS = pageState.getWindowNavigationalState(windowId);
- if (windowNS == null || windowNS.getWindowState().equals(WindowState.NORMAL))
+ if (windowNS == null || !windowNS.getWindowState().equals(WindowState.MINIMIZED))
{
if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
{
@@ -338,20 +406,20 @@
}
else
{
- writer.write(portletResponse.getClass().getSimpleName() + "[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
+ writer.write(portletResponse.getClass().getSimpleName() + "[" + startPortletChunk.getPortletName() + "," + startPortletChunk.getApplicationName() + "]");
writer.flush();
}
}
else
{
- writer.write("Empty[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
+ writer.write("Empty[" + startPortletChunk.getPortletName() + "," + startPortletChunk.getApplicationName() + "]");
writer.flush();
}
}
else if (chunk instanceof EndPortletChunk)
{
windowId = null;
- portletChunk = null;
+ startPortletChunk = null;
portletResponse = null;
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07 11:12:39 UTC (rev 9832)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -30,6 +30,7 @@
import java.util.Map;
import java.util.HashMap;
import java.util.List;
+import java.util.Collection;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -60,6 +61,11 @@
return windows.get(windowId);
}
+ public Collection<Window> getWindows()
+ {
+ return windows.values();
+ }
+
public Map<String, PortletInvocationResponse> render(PortletControllerContext context, PageNavigationalState pageState)
{
Map<String, PortletInvocationResponse> responses = new HashMap<String, PortletInvocationResponse>();
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-07 11:12:39 UTC (rev 9832)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -24,7 +24,7 @@
import org.jboss.portal.portlet.test.controller.AbstractPortletControllerContext;
import org.jboss.portal.portlet.test.jsp.response.Chunk;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletChunk;
import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -43,6 +43,7 @@
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
+import java.util.LinkedHashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -72,12 +73,12 @@
// Collect portlets to create the page
int counter = 0;
- Map<String, Window> windows = new HashMap<String, Window>();
+ Map<String, Window> windows = new LinkedHashMap<String, Window>();
for (Chunk chunk : buffer.getChunks())
{
- if (chunk instanceof PortletChunk)
+ if (chunk instanceof StartPortletChunk)
{
- PortletChunk portletChunk = (PortletChunk)chunk;
+ StartPortletChunk startPortletChunk = (StartPortletChunk)chunk;
String windowId = "" + counter++;
//
@@ -90,7 +91,7 @@
String applicationName = portletInfo.getApplicationName();
//
- if (applicationName.equals(portletChunk.getApplicationName()) && portletName.equals(portletChunk.getPortletName()))
+ if (applicationName.equals(startPortletChunk.getApplicationName()) && portletName.equals(startPortletChunk.getPortletName()))
{
windows.put(windowId, new Window(windowId, portlet));
}
@@ -104,6 +105,9 @@
}
//
+
+
+ //
this.page = new Page(buffer.getChunks(), windows);
this.invoker = invoker;
this.eventControllerContext = new EventControllerContextImpl(invoker);
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/EndPageChunk.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/EndPageChunk.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/EndPageChunk.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.response;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EndPageChunk extends Chunk
+{
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/StartPageChunk.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/StartPageChunk.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/StartPageChunk.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.response;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StartPageChunk extends Chunk
+{
+}
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletTitleChunk.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletTitleChunk.java 2008-02-07 11:12:39 UTC (rev 9832)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletTitleChunk.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -1,33 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2008, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.test.jsp.response.portlet;
-
-import org.jboss.portal.portlet.test.jsp.response.Chunk;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PortletTitleChunk extends Chunk
-{
-}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletChunk.java (from rev 9821, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletChunk.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletChunk.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletChunk.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.response.portlet;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StartPortletChunk extends Chunk
+{
+
+ /** . */
+ private final String portletName;
+
+ /** . */
+ private final String applicationName;
+
+ /** . */
+ private final Mode initialMode;
+
+ /** . */
+ private final Set<Mode> supportedModes;
+
+ /** . */
+ private final Set<WindowState> supportedWindowStates;
+
+ public StartPortletChunk(String portletName, String applicationName, Mode initialMode, Set<Mode> supportedModes, Set<WindowState> supportedWindowStates)
+ {
+ this.portletName = portletName;
+ this.applicationName = applicationName;
+ this.initialMode = initialMode;
+ this.supportedModes = supportedModes;
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public String getPortletName()
+ {
+ return portletName;
+ }
+
+ public String getApplicationName()
+ {
+ return applicationName;
+ }
+
+ public Mode getInitialMode()
+ {
+ return initialMode;
+ }
+
+ public Set<Mode> getSupportedModes()
+ {
+ return supportedModes;
+ }
+
+ public Set<WindowState> getSupportedWindowStates()
+ {
+ return supportedWindowStates;
+ }
+}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageTag.java 2008-02-07 11:12:39 UTC (rev 9832)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageTag.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -22,23 +22,31 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import javax.servlet.jsp.tagext.BodyTagSupport;
+import org.jboss.portal.portlet.test.jsp.response.StartPageChunk;
+import org.jboss.portal.portlet.test.jsp.response.EndPageChunk;
+
import javax.servlet.jsp.JspException;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class PageTag extends BodyTagSupport
+public class PageTag extends BodyChunkTagSupport
{
public int doStartTag() throws JspException
{
+ addChunk(new StartPageChunk());
+
+ //
return EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspException
{
+ addChunk(new EndPageChunk());
+
+ //
return EVAL_PAGE;
}
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-07 11:12:39 UTC (rev 9832)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-07 12:04:09 UTC (rev 9833)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.EndPortletChunk;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -161,7 +161,7 @@
}
//
- addChunk(new PortletChunk(
+ addChunk(new StartPortletChunk(
name,
applicationName,
initialMode,
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07 11:12:39 UTC (rev 9832)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07 12:04:09 UTC (rev 9833)
@@ -10,6 +10,8 @@
applicationName="google-weather-portlet">
-----------------------------------<br/>
<portal:portlettitle/><br/>
+<a href="<portal:portleturl windowState='maximized'/>">Maximized<a/><br/>
+<a href="<portal:portleturl windowState='normal'/>">Normal<a/><br/>
<a href="<portal:portleturl windowState='minimized'/>">Minimized<a/><br/>
<a href="<portal:portleturl><portal:param name='zipcode' value='20855'/></portal:portleturl>">Derwood<a/><br/>
-----------------------------------<br/>
16 years, 4 months
JBoss Portal SVN: r9832 - in modules/portlet/trunk/test/src: test/resources/simple-portal-war and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 06:12:39 -0500 (Thu, 07 Feb 2008)
New Revision: 9832
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTitleTag.java
Modified:
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld
modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
Log:
rename jsp tag markup and title to portletmarkup and portlettitle
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java (from rev 9831, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java 2008-02-07 11:12:39 UTC (rev 9832)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.taglib;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.PortletMarkupChunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletMarkupTag extends SimpleChunkTagSupport
+{
+ protected Chunk doChunkTag()
+ {
+ return new PortletMarkupChunk();
+ }
+}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTitleTag.java (from rev 9831, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTitleTag.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTitleTag.java 2008-02-07 11:12:39 UTC (rev 9832)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.taglib;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletTitleChunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletTitleTag extends SimpleChunkTagSupport
+{
+ protected Chunk doChunkTag()
+ {
+ return new StartPortletTitleChunk();
+ }
+}
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld 2008-02-07 11:10:06 UTC (rev 9831)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld 2008-02-07 11:12:39 UTC (rev 9832)
@@ -43,14 +43,14 @@
</tag>
<tag>
- <name>markup</name>
- <tag-class>org.jboss.portal.portlet.test.jsp.taglib.MarkupTag</tag-class>
+ <name>portletmarkup</name>
+ <tag-class>org.jboss.portal.portlet.test.jsp.taglib.PortletMarkupTag</tag-class>
<body-content>empty</body-content>
</tag>
<tag>
- <name>title</name>
- <tag-class>org.jboss.portal.portlet.test.jsp.taglib.TitleTag</tag-class>
+ <name>portlettitle</name>
+ <tag-class>org.jboss.portal.portlet.test.jsp.taglib.PortletTitleTag</tag-class>
<body-content>empty</body-content>
</tag>
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07 11:10:06 UTC (rev 9831)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07 11:12:39 UTC (rev 9832)
@@ -9,11 +9,11 @@
name="GoogleWeather"
applicationName="google-weather-portlet">
-----------------------------------<br/>
-<portal:title/><br/>
+<portal:portlettitle/><br/>
<a href="<portal:portleturl windowState='minimized'/>">Minimized<a/><br/>
<a href="<portal:portleturl><portal:param name='zipcode' value='20855'/></portal:portleturl>">Derwood<a/><br/>
-----------------------------------<br/>
- <portal:markup/>
+ <portal:portletmarkup/>
-----------------------------------<br/>
</portal:portlet>
****************************************************<br/>
@@ -21,9 +21,9 @@
name="GoogleMap"
applicationName="google-map-portlet">
-----------------------------------<br/>
-<portal:title/><br/>
+<portal:portlettitle/><br/>
-----------------------------------<br/>
- <portal:markup/>
+ <portal:portletmarkup/>
-----------------------------------<br/>
</portal:portlet>
****************************************************<br/>
@@ -31,9 +31,9 @@
name="RemoteControl"
applicationName="remotecontrol-portlet">
-----------------------------------<br/>
-<portal:title/><br/>
+<portal:portlettitle/><br/>
-----------------------------------<br/>
- <portal:markup/>
+ <portal:portletmarkup/>
-----------------------------------<br/>
</portal:portlet>
****************************************************<br/>
16 years, 4 months
JBoss Portal SVN: r9831 - in modules/portlet/trunk/test/src: main/java/org/jboss/portal/portlet/test/jsp and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-07 06:10:06 -0500 (Thu, 07 Feb 2008)
New Revision: 9831
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld
modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
Log:
add support for portleturl tag
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -125,11 +125,14 @@
parameters.put(LIFECYCLE_TYPE, type);
//
- String pageState;
+ String pageState = null;
try
{
- byte[] bytes = stateContext.serialize(pageNS);
- pageState = Tools.toHexString(bytes);
+ if (pageNS != null)
+ {
+ byte[] bytes = stateContext.serialize(pageNS);
+ pageState = Tools.toHexString(bytes);
+ }
}
catch (IOException e)
{
@@ -153,7 +156,10 @@
}
//
- parameters.put(PAGE_STATE, pageState);
+ if (pageState != null)
+ {
+ parameters.put(PAGE_STATE, pageState);
+ }
//
if (containerURL instanceof ActionURL)
@@ -190,7 +196,10 @@
//
StateString navigationalState = renderURL.getNavigationalState();
- parameters.put(NAVIGATIONAL_STATE, navigationalState.getStringValue());
+ if (navigationalState != null)
+ {
+ parameters.put(NAVIGATIONAL_STATE, navigationalState.getStringValue());
+ }
}
}
else
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -27,19 +27,28 @@
import org.jboss.portal.portlet.test.jsp.response.CharsChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletMarkupChunk;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.PortletURLChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.EndPortletChunk;
import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
+import org.jboss.portal.portlet.test.controller.PortletURLRenderer;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.controller.PortletController;
+import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.controller.response.ResourceResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -206,6 +215,10 @@
//
Page page = context.getPage();
+ if (pageState == null)
+ {
+ pageState = context.getStateControllerContext().createPageState();
+ }
//
Map<String, PortletInvocationResponse> responses = page.render(context, pageState);
@@ -216,6 +229,7 @@
//
int count = 0;
+ String windowId = null;
PortletChunk portletChunk = null;
PortletInvocationResponse portletResponse = null;
for (Chunk chunk : page.getChunks())
@@ -235,10 +249,10 @@
else if (chunk instanceof PortletChunk)
{
portletChunk = (PortletChunk)chunk;
- String windowId = "" + count++;
+ windowId = "" + count++;
portletResponse = responses.get(windowId);
}
- else if (chunk instanceof PortletTitleChunk)
+ else if (chunk instanceof StartPortletTitleChunk)
{
if (portletResponse != null)
{
@@ -250,28 +264,76 @@
}
}
}
- else if (chunk instanceof PortletMarkupChunk)
+ else if (chunk instanceof PortletURLChunk)
{
+ final PortletURLChunk portletURL = (PortletURLChunk)chunk;
if (portletResponse != null)
{
if (portletResponse instanceof FragmentResponse)
{
- FragmentResponse fragment = (FragmentResponse)portletResponse;
- if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ PortletURLRenderer renderer = new PortletURLRenderer(
+ (StateControllerContextImpl)context.getStateControllerContext(),
+ pageState,
+ windowId,
+ context.getClientRequest(),
+ context.getClientResponse());
+
+ RenderURL url = new RenderURL()
{
- String frag;
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ public StateString getNavigationalState()
{
- frag = fragment.getBytes().toString();
+ return null;
}
- else
+
+ public Map<String, String[]> getPublicNavigationalStateChanges()
{
- frag = fragment.getChars().toString();
+ return portletURL.getParams();
}
- //
- writer.write(frag);
- writer.flush();
+ public Mode getMode()
+ {
+ return portletURL.getMode();
+ }
+
+ public WindowState getWindowState()
+ {
+ return portletURL.getWindowState();
+ }
+ };
+
+ //
+ String renderedURL = renderer.renderURL(url, null, null, true);
+ writer.write(renderedURL);
+ writer.flush();
+ }
+ }
+ }
+ else if (chunk instanceof PortletMarkupChunk)
+ {
+ if (portletResponse != null)
+ {
+ if (portletResponse instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)portletResponse;
+ WindowNavigationalState windowNS = pageState.getWindowNavigationalState(windowId);
+ if (windowNS == null || windowNS.getWindowState().equals(WindowState.NORMAL))
+ {
+ if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ {
+ String frag;
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ frag = fragment.getBytes().toString();
+ }
+ else
+ {
+ frag = fragment.getChars().toString();
+ }
+
+ //
+ writer.write(frag);
+ writer.flush();
+ }
}
}
else
@@ -286,6 +348,12 @@
writer.flush();
}
}
+ else if (chunk instanceof EndPortletChunk)
+ {
+ windowId = null;
+ portletChunk = null;
+ portletResponse = null;
+ }
}
out.close();
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -62,12 +62,6 @@
public Map<String, PortletInvocationResponse> render(PortletControllerContext context, PageNavigationalState pageState)
{
- if (pageState == null)
- {
- pageState = context.getStateControllerContext().createPageState();
- }
-
- //
Map<String, PortletInvocationResponse> responses = new HashMap<String, PortletInvocationResponse>();
//
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -65,9 +65,4 @@
{
buffer.close();
}
-
- public void addChunk(Chunk chunk)
- {
- buffer.addChunk(chunk);
- }
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -49,11 +49,36 @@
/** . */
private PrintWriter writer;
+ /** . */
+ private boolean muted;
+
+ public boolean isMuted()
+ {
+ return muted;
+ }
+
+ public void setMuted(boolean muted)
+ {
+ this.muted = muted;
+ }
+
public List<Chunk> getChunks()
{
return chunks;
}
+ public void flush()
+ {
+ if (chunkWriter != null)
+ {
+ chunkWriter.writeChunk();
+ }
+ else if (chunkOutputStream != null)
+ {
+ chunkOutputStream.writeChunk();
+ }
+ }
+
public void close()
{
try
@@ -131,10 +156,15 @@
StringBuffer sb = getBuffer();
if (sb.length() > 0)
{
- char[] chars = new char[sb.length()];
- sb.getChars(0, sb.length(), chars, 0);
- CharsChunk chunk = new CharsChunk(chars);
- chunks.add(chunk);
+ if (!muted)
+ {
+ char[] chars = new char[sb.length()];
+ sb.getChars(0, sb.length(), chars, 0);
+ CharsChunk chunk = new CharsChunk(chars);
+ chunks.add(chunk);
+ }
+
+ //
sb.setLength(0);
}
}
@@ -161,12 +191,17 @@
public void writeChunk()
{
- if (bytebuffer.size() > 0)
+ if (bytebuffer.size() > 0 && !muted)
{
- byte[] bytes = bytebuffer.toByteArray();
+ if (!muted)
+ {
+ byte[] bytes = bytebuffer.toByteArray();
+ BytesChunk chunk = new BytesChunk(bytes);
+ chunks.add(chunk);
+ }
+
+ //
bytebuffer.reset();
- BytesChunk chunk = new BytesChunk(bytes);
- chunks.add(chunk);
}
}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.response.portlet;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EndPortletChunk extends Chunk
+{
+}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -23,11 +23,46 @@
package org.jboss.portal.portlet.test.jsp.response.portlet;
import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
public class PortletURLChunk extends Chunk
{
+
+ /** . */
+ private final Mode mode;
+
+ /** . */
+ private final WindowState windowState;
+
+ /** . */
+ private final Map<String, String[]> params;
+
+ public PortletURLChunk(Mode mode, WindowState windowState, Map<String, String[]> params)
+ {
+ this.mode = mode;
+ this.windowState = windowState;
+ this.params = params;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public Map<String, String[]> getParams()
+ {
+ return params;
+ }
}
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java (from rev 9821, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletTitleChunk.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.response.portlet;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StartPortletTitleChunk extends Chunk
+{
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.taglib;
+
+import javax.servlet.jsp.JspException;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AbstractURLTag extends BodyChunkTagSupport
+{
+
+ /** . */
+ private Map<String, String[]> params = new HashMap<String, String[]>();
+
+ public void setParam(String name, String value)
+ {
+ params.put(name, new String[]{value});
+ }
+
+ public Map<String, String[]> getParams()
+ {
+ return new HashMap<String, String[]>(params);
+ }
+
+ public void doInitBody() throws JspException
+ {
+ params.clear();
+ }
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.taglib;
+
+import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
+
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class BodyChunkTagSupport extends BodyTagSupport
+{
+
+ protected final ResponseBuffer getBuffer()
+ {
+ BufferingResponse response = (BufferingResponse)pageContext.getResponse();
+ return response.getBuffer();
+ }
+
+ protected void mute(boolean on) throws JspException
+ {
+ try
+ {
+ pageContext.getOut().flush();
+ BufferingResponse response = (BufferingResponse)pageContext.getResponse();
+ ResponseBuffer buffer = response.getBuffer();
+ buffer.flush();
+ buffer.setMuted(on);
+ }
+ catch (IOException e)
+ {
+ throw new JspException(e);
+ }
+ }
+
+ protected final void addChunk(Chunk chunk) throws JspException
+ {
+ try
+ {
+ pageContext.getOut().flush();
+ BufferingResponse response = (BufferingResponse)pageContext.getResponse();
+ response.getBuffer().addChunk(chunk);
+ }
+ catch (IOException e)
+ {
+ throw new JspException(e);
+ }
+ }
+}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -22,26 +22,17 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletMarkupChunk;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class MarkupTag extends SimpleTagSupport
+public class MarkupTag extends SimpleChunkTagSupport
{
- public void doTag() throws JspException, IOException
+ protected Chunk doChunkTag()
{
- PageContext pageCtx = (PageContext)getJspContext();
- pageCtx.getOut().flush();
- BufferingResponse response = (BufferingResponse)pageCtx.getResponse();
- response.addChunk(new PortletMarkupChunk());
+ return new PortletMarkupChunk();
}
}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.taglib;
+
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ParamTag extends SimpleTagSupport
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private String value;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void doTag() throws JspException, IOException
+ {
+ AbstractURLTag urlTag = (AbstractURLTag)SimpleTagSupport.findAncestorWithClass(this, AbstractURLTag.class);
+ urlTag.setParam(name, value);
+ }
+}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -22,16 +22,13 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.EndPortletChunk;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.Tools;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
-import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -41,7 +38,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class PortletTag extends BodyTagSupport
+public class PortletTag extends BodyChunkTagSupport
{
/** . */
@@ -164,8 +161,7 @@
}
//
- BufferingResponse response = (BufferingResponse)pageContext.getResponse();
- response.addChunk(new PortletChunk(
+ addChunk(new PortletChunk(
name,
applicationName,
initialMode,
@@ -178,6 +174,9 @@
public int doEndTag() throws JspException
{
+ addChunk(new EndPortletChunk());
+
+ //
return EVAL_PAGE;
}
}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.taglib;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.test.jsp.response.portlet.PortletURLChunk;
+
+import javax.servlet.jsp.JspException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletURLTag extends AbstractURLTag
+{
+
+ /** . */
+ private String modeValue;
+
+ /** . */
+ private String windowStateValue;
+
+ public String getMode()
+ {
+ return modeValue;
+ }
+
+ public void setMode(String mode)
+ {
+ this.modeValue = mode;
+ }
+
+ public String getWindowState()
+ {
+ return windowStateValue;
+ }
+
+ public void setWindowState(String windowState)
+ {
+ this.windowStateValue = windowState;
+ }
+
+ public int doStartTag() throws JspException
+ {
+ mute(true);
+
+ //
+ return EVAL_BODY_BUFFERED;
+ }
+
+ public int doEndTag() throws JspException
+ {
+ Mode mode = null;
+ if (modeValue != null)
+ {
+ mode = Mode.create(modeValue.trim());
+ }
+
+ //
+ WindowState windowState = null;
+ if (windowStateValue != null)
+ {
+ windowState = WindowState.create(windowStateValue.trim());
+ }
+
+ //
+ addChunk(new PortletURLChunk(mode, windowState, getParams()));
+
+ //
+ mute(false);
+
+ //
+ return EVAL_PAGE;
+ }
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.test.jsp.taglib;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
+
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class SimpleChunkTagSupport extends SimpleTagSupport
+{
+
+ public final void doTag() throws JspException, IOException
+ {
+ Chunk chunk = doChunkTag();
+
+ //
+ if (chunk != null)
+ {
+ PageContext pageCtx = (PageContext)getJspContext();
+ pageCtx.getOut().flush();
+ BufferingResponse response = (BufferingResponse)pageCtx.getResponse();
+ response.getBuffer().addChunk(chunk);
+ }
+ }
+
+ protected abstract Chunk doChunkTag();
+
+}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java 2008-02-07 11:10:06 UTC (rev 9831)
@@ -22,25 +22,17 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletTitleChunk;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class TitleTag extends SimpleTagSupport
+public class TitleTag extends SimpleChunkTagSupport
{
- public void doTag() throws JspException, IOException
+ protected Chunk doChunkTag()
{
- PageContext pageCtx = (PageContext)getJspContext();
- pageCtx.getOut().flush();
- BufferingResponse response = (BufferingResponse)pageCtx.getResponse();
- response.addChunk(new PortletTitleChunk());
+ return new StartPortletTitleChunk();
}
}
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld 2008-02-07 11:10:06 UTC (rev 9831)
@@ -54,4 +54,32 @@
<body-content>empty</body-content>
</tag>
+ <tag>
+ <name>portleturl</name>
+ <tag-class>org.jboss.portal.portlet.test.jsp.taglib.PortletURLTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <name>mode</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>windowState</name>
+ <type>java.lang.String</type>
+ </attribute>
+ </tag>
+
+ <tag>
+ <name>param</name>
+ <tag-class>org.jboss.portal.portlet.test.jsp.taglib.ParamTag</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <name>name</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>value</name>
+ <type>java.lang.String</type>
+ </attribute>
+ </tag>
+
</taglib>
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07 08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07 11:10:06 UTC (rev 9831)
@@ -10,6 +10,8 @@
applicationName="google-weather-portlet">
-----------------------------------<br/>
<portal:title/><br/>
+<a href="<portal:portleturl windowState='minimized'/>">Minimized<a/><br/>
+<a href="<portal:portleturl><portal:param name='zipcode' value='20855'/></portal:portleturl>">Derwood<a/><br/>
-----------------------------------<br/>
<portal:markup/>
-----------------------------------<br/>
16 years, 4 months
JBoss Portal SVN: r9830 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-02-07 03:31:51 -0500 (Thu, 07 Feb 2008)
New Revision: 9830
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml
Log:
minor updates to 5.2.1.1. Introduction
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml 2008-02-07 08:15:41 UTC (rev 9829)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/tutorials.xml 2008-02-07 08:31:51 UTC (rev 9830)
@@ -137,14 +137,13 @@
</sect2>-->
<sect2>
- <title>Deploying your first portlet</title>
+ <title>Deploying your First Portlet</title>
<sect3>
<title>Introduction</title>
- <para>This section will introduce the reader to deploying his first portlet in JBoss Portal. It requires you
- download the HelloWorldPortlet from PortletSwap.com, using this
- <ulink
- url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/HelloWorl...">link</ulink>.
- </para>
+ <para>
+ This section details deploying your first portlet in JBoss Portal. Before proceeding, download the <ulink
+ url="http://anonsvn.jboss.org/repos/portletswap/portlets/2_6/bundles/HelloWorl...">HelloWorldPorlet</ulink> from <ulink url="http://labs.jboss.com/portletswap/">JBoss PortletSwap</ulink>.
+ </para>
</sect3>
<sect3>
<title>Package Structure</title>
16 years, 4 months