Author: julien(a)jboss.com
Date: 2008-02-10 08:47:05 -0500 (Sun, 10 Feb 2008)
New Revision: 9918
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageParameterDef.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortletResult.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/WindowDef.java
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.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/PageEventControllerContext.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/PortalPrepareResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageParamTag.java
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/PortletTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
Log:
make portlet rendering ahead of JSP rendering (between prepare and render phases of
portal)
Modified:
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java
===================================================================
---
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/controller/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -123,7 +123,8 @@
public String[] getPublicNavigationalState(QName name)
{
- return page.get(name).clone();
+ String[] values = page.get(name);
+ return values != null ? values.clone() : null;
}
public void setWindowNavigationalState(String windowId, WindowNavigationalState
windowState)
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-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -88,13 +88,13 @@
PortletInvoker invoker =
(PortletInvoker)getServletContext().getAttribute("ConsumerPortletInvoker");
//
- PortalPrepareResponse prepareResponse = new PortalPrepareResponse(resp, invoker);
+ PortalPrepareResponse prepareResponse = new PortalPrepareResponse(resp);
// Discover existing portlets on the page (introspection phase)
chain.doFilter(req, prepareResponse);
// Now we can create a populated context
- PagePortletControllerContext context = new PagePortletControllerContext(req, resp,
getServletContext(), prepareResponse);
+ PagePortletControllerContext context = new PagePortletControllerContext(req, resp,
invoker, getServletContext(), prepareResponse);
//
PageNavigationalState pageState = null;
@@ -235,7 +235,7 @@
}
//
- PortalRenderResponse renderResponse = new PortalRenderResponse(resp, invoker,
context, pageState);
+ PortalRenderResponse renderResponse = new PortalRenderResponse(resp, context,
pageState, prepareResponse);
//
chain.doFilter(req, renderResponse);
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageEventControllerContext.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageEventControllerContext.java 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageEventControllerContext.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -25,6 +25,7 @@
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.controller.event.Event;
import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.info.PortletInfo;
import java.util.List;
@@ -43,8 +44,14 @@
/** . */
private final PortalPrepareResponse prepareResponse;
- public PageEventControllerContext(PortalPrepareResponse prepareResponse)
+ /** . */
+ private final PagePortletControllerContext context;
+
+ public PageEventControllerContext(
+ PagePortletControllerContext context,
+ PortalPrepareResponse prepareResponse)
{
+ this.context = context;
this.prepareResponse = prepareResponse;
}
@@ -55,16 +62,26 @@
//
for (String windowId : prepareResponse.getWindowIds())
{
- Portlet portlet = prepareResponse.getPortlet(windowId);
+ try
+ {
+ Portlet portlet = context.getPortlet(windowId);
- //
- PortletInfo portletInfo = portlet.getInfo();
+ //
+ if (portlet != null)
+ {
+ PortletInfo portletInfo = portlet.getInfo();
- //
- if
(portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
+ //
+ if
(portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
+ {
+ Event consumedEvent = new Event(producedEvent.getName(),
producedEvent.getPayload(), windowId);
+ consumedEvents.add(consumedEvent);
+ }
+ }
+ }
+ catch (PortletInvokerException e)
{
- Event consumedEvent = new Event(producedEvent.getName(),
producedEvent.getPayload(), windowId);
- consumedEvents.add(consumedEvent);
+ e.printStackTrace();
}
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageParameterDef.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageParameterDef.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageParameterDef.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PageParameterDef
+{
+
+ /** . */
+ private QName name;
+
+ /** . */
+ private String value;
+
+ /** . */
+ private boolean frozen;
+
+ public PageParameterDef(QName name, String value, boolean frozen)
+ {
+ this.name = name;
+ this.value = value;
+ this.frozen = frozen;
+ }
+
+ public QName getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public boolean isFrozen()
+ {
+ return frozen;
+ }
+}
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-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -24,6 +24,8 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
@@ -35,6 +37,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -49,9 +53,16 @@
/** . */
private final PortalPrepareResponse prepareResponse;
+ /** . */
+ private final Map<Key, Portlet> portlets;
+
+ /** . */
+ private final PortletInvoker invoker;
+
public PagePortletControllerContext(
HttpServletRequest req,
HttpServletResponse resp,
+ PortletInvoker invoker,
ServletContext servletContext,
PortalPrepareResponse prepareResponse)
throws IllegalRequestException, IOException, ServletException,
PortletInvokerException
@@ -59,22 +70,78 @@
super(req, resp, servletContext);
//
+ Map<Key, Portlet> portlets = new HashMap<Key, Portlet>();
+ for (Portlet portlet : invoker.getPortlets())
+ {
+ PortletInfo portletInfo = portlet.getInfo();
+ String portletName = portletInfo.getName();
+ String applicationName = portletInfo.getApplicationName();
+ Key key = new Key(applicationName, portletName);
+ portlets.put(key, portlet);
+ }
+
+ //
+ this.invoker = invoker;
+ this.portlets = portlets;
this.prepareResponse = prepareResponse;
- this.eventControllerContext = new PageEventControllerContext(prepareResponse);
+ this.eventControllerContext = new PageEventControllerContext(this,
prepareResponse);
}
+ public Portlet findPortlet(String applicationName, String portletName)
+ {
+ return portlets.get(new Key(applicationName, portletName));
+ }
+
protected Portlet getPortlet(String windowId) throws PortletInvokerException
{
- return prepareResponse.getPortlet(windowId);
+ WindowDef windowDef = prepareResponse.getWindowDef(windowId);
+
+ //
+ return findPortlet(windowDef.getApplicationName(), windowDef.getPortletName());
}
public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
{
- return prepareResponse.getInvoker().invoke(invocation);
+ return invoker.invoke(invocation);
}
public EventControllerContext getEventControllerContext()
{
return eventControllerContext;
}
+
+ private static class Key
+ {
+
+ /** . */
+ private final String applicationName;
+
+ /** . */
+ private final String portletName;
+
+ private Key(String applicationName, String portletName)
+ {
+ this.applicationName = applicationName;
+ this.portletName = portletName;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof Key)
+ {
+ Key that = (Key)obj;
+ return applicationName.equals(that.applicationName) &&
portletName.equals(that.portletName);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return applicationName.hashCode() + portletName.hashCode();
+ }
+ }
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalPrepareResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalPrepareResponse.java 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalPrepareResponse.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -22,13 +22,12 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.ServletOutputStream;
+import javax.xml.namespace.QName;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
@@ -63,31 +62,50 @@
private PrintWriter writer;
/** . */
- private Map<String, Portlet> windows;
+ private Map<String, WindowDef> windowDefs;
- public PortalPrepareResponse(HttpServletResponse response, PortletInvoker invoker)
throws PortletInvokerException
+ /** . */
+ private Map<QName, PageParameterDef> paramDefs;
+
+ public PortalPrepareResponse(HttpServletResponse response) throws
PortletInvokerException
{
- super(response, invoker);
+ super(response);
//
- this.windows = new HashMap<String, Portlet>();
+ this.windowDefs = new HashMap<String, WindowDef>();
+ this.paramDefs = new HashMap<QName, PageParameterDef>();
}
- public void addWindow(String windowId, Portlet portlet)
+ public Set<String> getWindowIds()
{
- windows.put(windowId, portlet);
+ return windowDefs.keySet();
}
- public Set<String> getWindowIds()
+ public WindowDef getWindowDef(String windowId)
{
- return windows.keySet();
+ return windowDefs.get(windowId);
}
- public Portlet getPortlet(String windowId)
+ public void addWindowDef(String windowId, WindowDef portlet)
{
- return windows.get(windowId);
+ windowDefs.put(windowId, portlet);
}
+ public Set<QName> getPageParameterNames()
+ {
+ return paramDefs.keySet();
+ }
+
+ public PageParameterDef getPageParameterDef(QName name)
+ {
+ return paramDefs.get(name);
+ }
+
+ public void setPageParameterDef(PageParameterDef parameterDef)
+ {
+ paramDefs.put(parameterDef.getName(), parameterDef);
+ }
+
public ServletOutputStream getOutputStream() throws IOException
{
if (writer != null)
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.test.controller.TestInstanceContext;
import org.jboss.portal.portlet.test.controller.TestPortalContext;
+import org.jboss.portal.portlet.test.jsp.PortletResult;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
@@ -31,7 +32,6 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
@@ -44,6 +44,9 @@
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -55,24 +58,46 @@
/** . */
private PageNavigationalState pageState;
- /** Wether or not the page state can be modified. */
- private boolean pageStateModifiable;
-
/** . */
private PagePortletControllerContext portletControllerContext;
+ /** . */
+ private Map<String, PortletResult> windowResults;
+
public PortalRenderResponse(
HttpServletResponse response,
- PortletInvoker invoker,
PagePortletControllerContext portletControllerContext,
- PageNavigationalState pageState) throws PortletInvokerException
+ PageNavigationalState pageState,
+ PortalPrepareResponse prepareResponse) throws PortletInvokerException
{
- super(response, invoker);
+ super(response);
//
+ Set<QName> pageParameterNames = prepareResponse.getPageParameterNames();
+ if (pageParameterNames.size() > 0)
+ {
+ if (pageState == null)
+ {
+ pageState =
portletControllerContext.getStateControllerContext().createPageState(true);
+ }
+ for (QName parameterName : pageParameterNames)
+ {
+ PageParameterDef parameterDef =
prepareResponse.getPageParameterDef(parameterName);
+ boolean update = parameterDef.isFrozen() ? true :
pageState.getPublicNavigationalState(parameterName) == null;
+ if (update)
+ {
+ pageState.setPublicNavigationalState(parameterName, new
String[]{parameterDef.getValue()});
+ }
+ }
+ }
+
+ //
+ this.portletControllerContext = portletControllerContext;
+ this.windowResults = new HashMap<String, PortletResult>();
this.pageState = pageState;
- this.pageStateModifiable = true;
- this.portletControllerContext = portletControllerContext;
+
+ //
+ render(prepareResponse);
}
/**
@@ -85,12 +110,17 @@
return pageState;
}
+ public PortletResult getWindowResult(String windowId)
+ {
+ return windowResults.get(windowId);
+ }
+
public PagePortletControllerContext getPortletControllerContext()
{
return portletControllerContext;
}
- public PortletInvocationResponse render(Portlet portlet, String windowId) throws
PortletInvokerException
+ private PortletInvocationResponse render(Portlet portlet, String windowId) throws
PortletInvokerException
{
WindowNavigationalState windowNS = null;
if (pageState != null)
@@ -144,36 +174,41 @@
render.setPublicNavigationalState(publicNS);
//
- pageStateModifiable = false;
-
- //
return portletControllerContext.invoke(render);
}
- public boolean isPageStateModifiable()
+ private void render(PortalPrepareResponse prepareResponse)
{
- return pageStateModifiable;
- }
+ for (String windowId : prepareResponse.getWindowIds())
+ {
+ WindowDef windowDef = prepareResponse.getWindowDef(windowId);
- public String getPageParameter(QName name)
- {
- return pageState != null ? pageState.getPublicNavigationalState(name)[0] : null;
- }
+ //
+ try
+ {
+ Portlet portlet = portletControllerContext.getPortlet(windowId);
- public void setPageParameter(QName name, String value)
- {
- if (pageStateModifiable)
- {
- if (pageState == null)
+ //
+ if (portlet != null)
+ {
+ PortletInvocationResponse portletResponse = render(portlet, windowId);
+
+ //
+ PortletResult result = new PortletResult(windowDef, portletResponse);
+
+ //
+ windowResults.put(windowId, result);
+ }
+ else
+ {
+ // log
+ }
+ }
+ catch (PortletInvokerException e)
{
- pageState =
portletControllerContext.getStateControllerContext().createPageState(true);
+ e.printStackTrace();
}
- pageState.setPublicNavigationalState(name, new String[]{value});
}
- else
- {
- throw new IllegalStateException("Page state cannot be modified");
- }
}
public String getMaximizedWindowId()
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalResponse.java 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalResponse.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -22,15 +22,10 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.info.PortletInfo;
import javax.servlet.http.HttpServletResponseWrapper;
import javax.servlet.http.HttpServletResponse;
-import java.util.Map;
-import java.util.HashMap;
/**
* Expose stuff common to action and render response.
@@ -42,46 +37,13 @@
{
/** . */
- private final PortletInvoker invoker;
-
- /** . */
- private final Map<Key, Portlet> portlets;
-
- /** . */
private int count = 0;
- public PortalResponse(
- HttpServletResponse response,
- PortletInvoker invoker) throws PortletInvokerException
+ public PortalResponse(HttpServletResponse response) throws PortletInvokerException
{
super(response);
-
- //
- Map<Key, Portlet> portlets = new HashMap<Key, Portlet>();
- for (Portlet portlet : invoker.getPortlets())
- {
- PortletInfo portletInfo = portlet.getInfo();
- String portletName = portletInfo.getName();
- String applicationName = portletInfo.getApplicationName();
- Key key = new Key(applicationName, portletName);
- portlets.put(key, portlet);
- }
-
- //
- this.portlets = portlets;
- this.invoker = invoker;
}
- public PortletInvoker getInvoker()
- {
- return invoker;
- }
-
- public Portlet findPortlet(String applicationName, String portletName)
- {
- return portlets.get(new Key(applicationName, portletName));
- }
-
/**
* todo : add on JSP portlet tag a notion of 'id', because this id generation
relies on the portlet
* rendering order on the page which could not be the same between 2 requests.
@@ -90,39 +52,4 @@
{
return "" + count++;
}
-
- private static class Key
- {
-
- /** . */
- private final String applicationName;
-
- /** . */
- private final String portletName;
-
- private Key(String applicationName, String portletName)
- {
- this.applicationName = applicationName;
- this.portletName = portletName;
- }
-
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
- if (obj instanceof Key)
- {
- Key that = (Key)obj;
- return applicationName.equals(that.applicationName) &&
portletName.equals(that.portletName);
- }
- return false;
- }
-
- public int hashCode()
- {
- return applicationName.hashCode() + portletName.hashCode();
- }
- }
}
Copied:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortletResult.java
(from rev 9913,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletResult.java)
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortletResult.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortletResult.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.test.jsp.WindowDef;
+
+/**
+ * Combines the invocation of a portlet and the info on the portlet JSP tag. It does
+ * not need to be exposed out of this package.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletResult
+{
+
+ /** . */
+ private final WindowDef windowDef;
+
+ /** . */
+ private final PortletInvocationResponse response;
+
+ public PortletResult(WindowDef windowDef, PortletInvocationResponse response)
+ {
+ this.windowDef = windowDef;
+ this.response = response;
+ }
+
+ public WindowDef getWindowDef()
+ {
+ return windowDef;
+ }
+
+ public PortletInvocationResponse getResponse()
+ {
+ return response;
+ }
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/WindowDef.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/WindowDef.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/WindowDef.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -0,0 +1,103 @@
+/******************************************************************************
+ * 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;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import java.util.Set;
+
+/**
+ * Combines the invocation of a portlet and the info on the portlet JSP tag. It does
+ * not need to be exposed out of this package.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class WindowDef
+{
+
+ /** . */
+ private final String portletName;
+
+ /** . */
+ private final String applicationName;
+
+ /** . */
+ private final String windowId;
+
+ /** . */
+ private final Mode initialMode;
+
+ /** . */
+ private final Set<Mode> supportedModes;
+
+ /** . */
+ private final Set<WindowState> supportedWindowStates;
+
+ public WindowDef(
+ String portletName,
+ String applicationName,
+ String windowId,
+ Mode initialMode,
+ Set<Mode> supportedModes,
+ Set<WindowState> supportedWindowStates)
+ {
+ this.portletName = portletName;
+ this.applicationName = applicationName;
+ this.windowId = windowId;
+ this.initialMode = initialMode;
+ this.supportedModes = supportedModes;
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public String getPortletName()
+ {
+ return portletName;
+ }
+
+ public String getApplicationName()
+ {
+ return applicationName;
+ }
+
+ public String getWindowId()
+ {
+ return windowId;
+ }
+
+ public Mode getInitialMode()
+ {
+ return initialMode;
+ }
+
+ public Set<Mode> getSupportedModes()
+ {
+ return supportedModes;
+ }
+
+ public Set<WindowState> getSupportedWindowStates()
+ {
+ return supportedWindowStates;
+ }
+}
\ No newline at end of file
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageParamTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageParamTag.java 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageParamTag.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
import org.jboss.portal.portlet.test.jsp.PortalPrepareResponse;
+import org.jboss.portal.portlet.test.jsp.PageParameterDef;
import javax.servlet.jsp.JspException;
import javax.xml.namespace.QName;
@@ -37,76 +38,66 @@
{
/** . */
- private String namespaceURI;
+ private String namespaceURIAttr;
/** . */
- private String localName;
+ private String localNameAttr;
/** . */
- private String value;
+ private String valueAttr;
/** . */
- private String frozen;
+ private String frozenAttr;
public String getNamespaceURI()
{
- return namespaceURI;
+ return namespaceURIAttr;
}
public void setNamespaceURI(String namespaceURI)
{
- this.namespaceURI = namespaceURI;
+ this.namespaceURIAttr = namespaceURI;
}
public String getLocalName()
{
- return localName;
+ return localNameAttr;
}
public void setLocalName(String localName)
{
- this.localName = localName;
+ this.localNameAttr = localName;
}
public String getValue()
{
- return value;
+ return valueAttr;
}
public void setValue(String value)
{
- this.value = value;
+ this.valueAttr = value;
}
public String getFrozen()
{
- return frozen;
+ return frozenAttr;
}
public void setFrozen(String frozen)
{
- this.frozen = frozen;
+ this.frozenAttr = frozen;
}
public void doTag(PortalRenderResponse renderResponse) throws JspException,
IOException
{
- if (renderResponse.isPageStateModifiable())
- {
- QName name = new QName(namespaceURI, localName);
-
- //
- if ("true".equals(frozen))
- {
- //
- }
- else if (renderResponse.getPageParameter(name) == null)
- {
- renderResponse.setPageParameter(name, value);
- }
- }
}
public void doTag(PortalPrepareResponse prepareResponse) throws JspException,
IOException
{
+ QName name = new QName(namespaceURIAttr, localNameAttr);
+ boolean frozen = "true".equals(frozenAttr);
+ PageParameterDef parameterDef = new PageParameterDef(name, valueAttr, frozen);
+ prepareResponse.setPageParameterDef(parameterDef);
}
}
Modified:
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/PortletMarkupTag.java 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -55,7 +55,7 @@
WindowNavigationalState windowNS = null;
if (renderResponse.getPageState() != null)
{
- windowNS =
renderResponse.getPageState().getWindowNavigationalState(portletTag.result.getWindowId());
+ windowNS =
renderResponse.getPageState().getWindowNavigationalState(portletTag.result.getWindowDef().getWindowId());
}
if (windowNS == null ||
!windowNS.getWindowState().equals(WindowState.MINIMIZED))
{
@@ -77,13 +77,13 @@
}
else
{
- out.write(portletResp.getClass().getSimpleName() + "[" +
portletTag.result.getPortletName() + "," +
portletTag.result.getApplicationName() + "]");
+ out.write(portletResp.getClass().getSimpleName() + "[" +
portletTag.result.getWindowDef().getPortletName() + "," +
portletTag.result.getWindowDef().getApplicationName() + "]");
out.flush();
}
}
else
{
- out.write("Empty[" + portletTag.result.getPortletName() +
"," + portletTag.result.getApplicationName() + "]");
+ out.write("Empty[" + portletTag.result.getWindowDef().getPortletName()
+ "," + portletTag.result.getWindowDef().getApplicationName() + "]");
out.flush();
}
}
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-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -25,12 +25,12 @@
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
import org.jboss.portal.portlet.test.jsp.PortalPrepareResponse;
import org.jboss.portal.portlet.test.jsp.PortalResponse;
+import org.jboss.portal.portlet.test.jsp.WindowDef;
+import org.jboss.portal.portlet.test.jsp.PortletResult;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.Tools;
@@ -79,10 +79,8 @@
private Set<Mode> supportedModes;
private Mode initialMode;
private PageTag pageTag;
- private Portlet portlet;
private String windowId;
- /** . */
PortletResult result;
public String getName()
@@ -185,9 +183,6 @@
}
//
- Portlet portlet = portalResponse.findPortlet(applicationNameAttr, nameAttr);
-
- //
String windowId = portalResponse.nextId();
//
@@ -195,7 +190,6 @@
this.supportedModes = supportedModes;
this.supportedWindowStates = supportedWindowStates;
this.pageTag = (PageTag)findAncestorWithClass(this, PageTag.class);
- this.portlet = portlet;
this.windowId = windowId;
}
@@ -205,7 +199,6 @@
this.supportedModes = null;
this.supportedWindowStates = null;
this.pageTag = null;
- this.portlet = null;
this.windowId = null;
}
@@ -214,12 +207,12 @@
initState(prepareResponse);
//
- if (portlet != null)
- {
- prepareResponse.addWindow(windowId, portlet);
- }
+ WindowDef windowDef = new WindowDef(nameAttr, applicationNameAttr, windowId,
initialMode, supportedModes, supportedWindowStates);
//
+ prepareResponse.addWindowDef(windowId, windowDef);
+
+ //
return SKIP_BODY;
}
@@ -236,7 +229,10 @@
initState(renderResponse);
//
- if (portlet == null)
+ PortletResult result = renderResponse.getWindowResult(windowId);
+
+ //
+ if (result == null || result.getResponse() == null)
{
handleError(renderResponse, Constants.NOT_FOUND, null, null);
@@ -249,7 +245,7 @@
{
if (windowId.equals(pageTag.maximizedId))
{
- return render(renderResponse, EVAL_BODY_BUFFERED);
+ return render(renderResponse, result, EVAL_BODY_BUFFERED);
}
else
{
@@ -258,7 +254,7 @@
}
else
{
- return render(renderResponse, EVAL_BODY_INCLUDE);
+ return render(renderResponse, result, EVAL_BODY_INCLUDE);
}
}
}
@@ -277,55 +273,37 @@
return EVAL_PAGE;
}
- public int render(PortalRenderResponse renderResponse, int rt)
+ public int render(PortalRenderResponse renderResponse, PortletResult result, int rt)
{
- try
+ PortletInvocationResponse portletResponse = result.getResponse();
+
+ //
+ if (portletResponse instanceof FragmentResponse)
{
- PortletInvocationResponse portletResponse = renderResponse.render(portlet,
windowId);
+ this.result = result;
+ //
+ return rt;
+ }
+ else if (portletResponse instanceof ErrorResponse)
+ {
+ ErrorResponse error = (ErrorResponse)portletResponse;
//
- if (portletResponse instanceof FragmentResponse)
- {
- result = new PortletResult(
- nameAttr,
- applicationNameAttr,
- windowId,
- portletResponse,
- initialMode,
- supportedModes,
- supportedWindowStates);
+ handleError(renderResponse, Constants.PORTLET_ERROR, error.getCause(),
error.getMessage());
- //
- return rt;
- }
- else if (portletResponse instanceof ErrorResponse)
- {
- ErrorResponse error = (ErrorResponse)portletResponse;
+ //
+ return SKIP_BODY;
+ }
+ else if (portletResponse instanceof UnavailableResponse)
+ {
+ handleError(renderResponse, Constants.UNAVAILABLE, null, null);
- //
- handleError(renderResponse, Constants.PORTLET_ERROR, error.getCause(),
error.getMessage());
-
- //
- return SKIP_BODY;
- }
- else if (portletResponse instanceof UnavailableResponse)
- {
- handleError(renderResponse, Constants.UNAVAILABLE, null, null);
-
- //
- return SKIP_BODY;
- }
- else
- {
- handleError(renderResponse, Constants.INTERNAL_ERROR, null, null);
-
- //
- return SKIP_BODY;
- }
+ //
+ return SKIP_BODY;
}
- catch (PortletInvokerException e)
+ else
{
- handleError(renderResponse, Constants.INTERNAL_ERROR, e, e.getMessage());
+ handleError(renderResponse, Constants.INTERNAL_ERROR, null, null);
//
return SKIP_BODY;
Modified:
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 2008-02-10
04:31:21 UTC (rev 9917)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-10
13:47:05 UTC (rev 9918)
@@ -130,7 +130,7 @@
try
{
JspWriter out = pageContext.getOut();
- String renderedURL = renderer.renderURL(portletTag.result.getWindowId(), url,
null, null, true);
+ String renderedURL =
renderer.renderURL(portletTag.result.getWindowDef().getWindowId(), url, null, null,
true);
out.write(renderedURL);
}
catch (IOException e)