Author: julien(a)jboss.com
Date: 2008-02-09 11:11:00 -0500 (Sat, 09 Feb 2008)
New Revision: 9901
Added:
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/PortalActionResponse.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalResponse.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/PagePortletControllerContext.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/taglib/PageParamTag.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/ParamTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortalBodyTagSupport.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortalSimpleTagSupport.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/PortletTitleTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
Log:
PageEventControllerContext that use the page structure to route events (thanks Chris, I
totally missed the use case)
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp;
-import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
import org.jboss.portal.portlet.test.controller.PortletURLRenderer;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -72,13 +71,25 @@
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws IOException, ServletException
{
- doFilter((HttpServletRequest)req, (HttpServletResponse)resp, chain);
+ try
+ {
+ doFilter((HttpServletRequest)req, (HttpServletResponse)resp, chain);
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new ServletException(e);
+ }
}
- public void doFilter(HttpServletRequest req, HttpServletResponse resp, FilterChain
chain) throws IOException, ServletException
+ public void doFilter(HttpServletRequest req, HttpServletResponse resp, FilterChain
chain) throws IOException, ServletException, PortletInvokerException
{
PortletInvoker invoker =
(PortletInvoker)getServletContext().getAttribute("ConsumerPortletInvoker");
+
+ PortalActionResponse actionResponse = new PortalActionResponse(resp, invoker);
+
+ chain.doFilter(req, actionResponse);
+
//
PagePortletControllerContext context;
try
@@ -87,7 +98,7 @@
req,
resp,
getServletContext(),
- invoker);
+ actionResponse);
}
catch (PortletInvokerException e)
{
@@ -97,6 +108,9 @@
PageNavigationalState pageState = null;
if (context.getRequest() != null)
{
+
+
+
ControllerResponse controllerResponse;
try
{
@@ -207,7 +221,7 @@
}
//
- PortalRenderResponse renderResponse = new PortalRenderResponse(resp, context,
pageState);
+ PortalRenderResponse renderResponse = new PortalRenderResponse(resp, invoker,
context, pageState);
//
chain.doFilter(req, renderResponse);
Added:
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
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PageEventControllerContext.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.event.Event;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.info.PortletInfo;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PageEventControllerContext implements EventControllerContext
+{
+
+ /** . */
+ private final PortalActionResponse actionResponse;
+
+ public PageEventControllerContext(PortalActionResponse actionResponse)
+ {
+ this.actionResponse = actionResponse;
+ }
+
+ public List<Event> getConsumedEvents(Event producedEvent)
+ {
+ ArrayList<Event> consumedEvents = new ArrayList<Event>();
+
+ //
+ for (String windowId : actionResponse.getWindowIds())
+ {
+ Portlet portlet = actionResponse.getPortlet(windowId);
+
+ //
+ PortletInfo portletInfo = portlet.getInfo();
+
+ //
+ if
(portletInfo.getEventing().getConsumedEvents().containsKey(producedEvent.getName()))
+ {
+ Event consumedEvent = new Event(producedEvent.getName(),
producedEvent.getPayload(), windowId);
+ consumedEvents.add(consumedEvent);
+ }
+ }
+
+ //
+ return consumedEvents;
+ }
+}
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -24,11 +24,8 @@
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
-import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.controller.event.EventControllerContext;
-import org.jboss.portal.portlet.controller.impl.event.EventControllerContextImpl;
-import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.test.controller.AbstractPortletControllerContext;
@@ -39,8 +36,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -50,45 +45,25 @@
{
/** . */
- private final PortletInvoker invoker;
-
- /** . */
private final EventControllerContext eventControllerContext;
/** . */
- private final Map<Key, Portlet> portlets;
+ private final PortalResponse actionResponse;
public PagePortletControllerContext(
HttpServletRequest req,
HttpServletResponse resp,
ServletContext servletContext,
- PortletInvoker invoker)
+ PortalActionResponse actionResponse)
throws IllegalRequestException, IOException, ServletException,
PortletInvokerException
{
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.portlets = portlets;
- this.invoker = invoker;
- this.eventControllerContext = new EventControllerContextImpl(invoker);
+ this.actionResponse = actionResponse;
+ this.eventControllerContext = new PageEventControllerContext(actionResponse);
}
- public Portlet findPortlet(String applicationName, String portletName)
- {
- return portlets.get(new Key(applicationName, portletName));
- }
-
protected Portlet getPortlet(String windowId) throws PortletInvokerException
{
int index = windowId.lastIndexOf('.');
@@ -96,58 +71,24 @@
// in the case of an event propagation, the given 'windowId' is actually
the portlet id already so need to check
// for that case (portletId should still have a '.', if not it means that
the windowId was really a portlet id)
- if (portletId.indexOf('.') == -1)
- {
- portletId = windowId;
- }
+// if (portletId.indexOf('.') == -1)
+// {
+// portletId = windowId;
+// }
PortletContext portletContext = PortletContext.createPortletContext(portletId);
- return invoker.getPortlet(portletContext);
+
+ //
+ return actionResponse.getInvoker().getPortlet(portletContext);
}
public PortletInvocationResponse invoke(PortletInvocation invocation) throws
PortletInvokerException
{
- return invoker.invoke(invocation);
+ return actionResponse.getInvoker().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();
- }
- }
-
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalActionResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalActionResponse.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalActionResponse.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -0,0 +1,242 @@
+/******************************************************************************
+ * 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.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 java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortalActionResponse extends PortalResponse
+{
+
+ /** . */
+ private String contentType;
+
+ /** . */
+ private Locale locale;
+
+ /** . */
+ private String characterEncoding;
+
+ /** . */
+ private int bufferSize;
+
+ /** . */
+ private ServletOutputStream outputStream;
+
+ /** . */
+ private PrintWriter writer;
+
+ /** . */
+ private Map<String, Portlet> windows;
+
+ public PortalActionResponse(HttpServletResponse response, PortletInvoker invoker)
throws PortletInvokerException
+ {
+ super(response, invoker);
+
+ //
+ this.windows = new HashMap<String, Portlet>();
+ }
+
+ public void addWindow(String windowId, Portlet portlet)
+ {
+ windows.put(windowId, portlet);
+ }
+
+ public Set<String> getWindowIds()
+ {
+ return windows.keySet();
+ }
+
+ public Portlet getPortlet(String windowId)
+ {
+ return windows.get(windowId);
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ if (writer != null)
+ {
+ throw new IllegalStateException();
+ }
+ if (outputStream == null)
+ {
+ outputStream = new ServletOutputStream()
+ {
+ public void write(int b) throws IOException
+ {
+ }
+ };
+ }
+ return outputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ if (outputStream != null)
+ {
+ throw new IllegalStateException();
+ }
+ if (writer == null)
+ {
+ Writer tmp = new Writer()
+ {
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ }
+ public void flush() throws IOException
+ {
+ }
+ public void close() throws IOException
+ {
+ }
+ };
+ writer = new PrintWriter(tmp);
+ }
+ return writer;
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ }
+
+ public boolean isCommitted()
+ {
+ return false;
+ }
+
+ public void reset()
+ {
+ }
+
+ public void resetBuffer()
+ {
+ }
+
+ public void sendError(int i, String s) throws IOException
+ {
+ }
+
+ public void sendError(int i) throws IOException
+ {
+ }
+
+ public void sendRedirect(String s) throws IOException
+ {
+ }
+
+ public void addCookie(Cookie cookie)
+ {
+ }
+
+ public void setDateHeader(String s, long l)
+ {
+ }
+
+ public void addDateHeader(String s, long l)
+ {
+ }
+
+ public void setHeader(String s, String s1)
+ {
+ }
+
+ public void addHeader(String s, String s1)
+ {
+ }
+
+ public void setContentType(String contentType)
+ {
+ this.contentType = contentType;
+ }
+
+ public void setContentLength(int i)
+ {
+ }
+
+ public void setCharacterEncoding(String characterEncoding)
+ {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public void setIntHeader(String s, int i)
+ {
+ }
+
+ public void addIntHeader(String s, int i)
+ {
+ }
+
+ public void setStatus(int i)
+ {
+ }
+
+ public void setStatus(int i, String s)
+ {
+ }
+
+ public void setLocale(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public void setBufferSize(int bufferSize)
+ {
+ this.bufferSize = bufferSize;
+ }
+
+ public int getBufferSize()
+ {
+ return bufferSize;
+ }
+}
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalRenderResponse.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -31,6 +31,7 @@
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;
@@ -42,39 +43,36 @@
import org.jboss.portal.common.util.ParameterMap;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
import javax.xml.namespace.QName;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class PortalRenderResponse extends HttpServletResponseWrapper
+public class PortalRenderResponse extends PortalResponse
{
/** . */
- private final PagePortletControllerContext portletControllerContext;
-
- /** . */
private PageNavigationalState pageState;
- /** . */
- private int count = 0;
-
/** Wether or not the page state can be modified. */
private boolean pageStateModifiable;
+ /** . */
+ private PagePortletControllerContext portletControllerContext;
+
public PortalRenderResponse(
HttpServletResponse response,
+ PortletInvoker invoker,
PagePortletControllerContext portletControllerContext,
- PageNavigationalState pageState)
+ PageNavigationalState pageState) throws PortletInvokerException
{
- super(response);
+ super(response, invoker);
//
- this.portletControllerContext = portletControllerContext;
this.pageState = pageState;
this.pageStateModifiable = true;
+ this.portletControllerContext = portletControllerContext;
}
/**
@@ -87,6 +85,11 @@
return pageState;
}
+ public PagePortletControllerContext getPortletControllerContext()
+ {
+ return portletControllerContext;
+ }
+
public PortletInvocationResponse render(Portlet portlet, String windowId) throws
PortletInvokerException
{
WindowNavigationalState windowNS = null;
@@ -190,14 +193,4 @@
//
return null;
}
-
- public PagePortletControllerContext getPortletControllerContext()
- {
- return portletControllerContext;
- }
-
- public String nextId()
- {
- return "" + count++;
- }
}
Deleted:
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PortalResponse.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -1,203 +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;
-
-import org.jboss.portal.portlet.test.controller.TestInstanceContext;
-import org.jboss.portal.portlet.test.controller.TestPortalContext;
-import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.impl.spi.AbstractClientContext;
-import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
-import org.jboss.portal.portlet.impl.spi.AbstractUserContext;
-import org.jboss.portal.portlet.impl.spi.AbstractWindowContext;
-import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
-import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.ParameterMap;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-import javax.xml.namespace.QName;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class PortalResponse extends HttpServletResponseWrapper
-{
-
- /** . */
- private final PagePortletControllerContext portletControllerContext;
-
- /** . */
- private PageNavigationalState pageState;
-
- /** . */
- private int count = 0;
-
- /** Wether or not the page state can be modified. */
- private boolean pageStateModifiable;
-
- public PortalResponse(
- HttpServletResponse response,
- PagePortletControllerContext portletControllerContext,
- PageNavigationalState pageState)
- {
- super(response);
-
- //
- this.portletControllerContext = portletControllerContext;
- this.pageState = pageState;
- this.pageStateModifiable = true;
- }
-
- /**
- * The page state for the rendering.
- *
- * @return the page state
- */
- public PageNavigationalState getPageState()
- {
- return pageState;
- }
-
- public PortletInvocationResponse render(Portlet portlet, String windowId) throws
PortletInvokerException
- {
- WindowNavigationalState windowNS = null;
- if (pageState != null)
- {
- windowNS = pageState.getWindowNavigationalState(windowId);
- }
-
- //
- ParameterMap publicNS = null;
- if (pageState != null)
- {
- publicNS = pageState.getPublicNavigationalState(windowId);
- }
-
- //
- Mode mode = Mode.VIEW;
- WindowState windowState = WindowState.NORMAL;
- StateString portletNS = null;
-
- //
- if (windowNS != null)
- {
- if (windowNS.getMode() != null)
- {
- mode = windowNS.getMode();
- }
- if (windowNS.getWindowState() != null)
- {
- windowState = windowNS.getWindowState();
- }
- if (windowNS.getPortletNavigationalState() != null)
- {
- portletNS = windowNS.getPortletNavigationalState();
- }
- }
-
- //
- PortletInvocationContext renderContext =
portletControllerContext.createPortletInvocationContext(windowId, pageState);
- RenderInvocation render = new RenderInvocation(renderContext);
- render.setClientContext(new
AbstractClientContext(portletControllerContext.getClientRequest()));
- render.setServerContext(new
AbstractServerContext(portletControllerContext.getClientRequest(),
portletControllerContext.getClientResponse()));
- render.setInstanceContext(new
TestInstanceContext(portletControllerContext.getClientRequest(), portlet.getContext(),
false));
- render.setUserContext(new
AbstractUserContext(portletControllerContext.getClientRequest()));
- render.setWindowContext(new AbstractWindowContext(windowId));
- render.setPortalContext(new TestPortalContext());
- render.setSecurityContext(new
AbstractSecurityContext(portletControllerContext.getClientRequest()));
- render.setTarget(portlet.getContext());
- render.setMode(mode);
- render.setWindowState(windowState);
- render.setNavigationalState(portletNS);
- render.setPublicNavigationalState(publicNS);
-
- //
- pageStateModifiable = false;
-
- //
- return portletControllerContext.invoke(render);
- }
-
- public boolean isPageStateModifiable()
- {
- return pageStateModifiable;
- }
-
- public String getPageParameter(QName name)
- {
- return pageState != null ? pageState.getPublicNavigationalState(name)[0] : null;
- }
-
- public void setPageParameter(QName name, String value)
- {
- if (pageStateModifiable)
- {
- if (pageState == null)
- {
- pageState =
portletControllerContext.getStateControllerContext().createPageState(true);
- }
- pageState.setPublicNavigationalState(name, new String[]{value});
- }
- else
- {
- throw new IllegalStateException("Page state cannot be modified");
- }
- }
-
- public String getMaximizedWindowId()
- {
- if (pageState != null)
- {
- for (String windowId : pageState.getWindowIds())
- {
- WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(windowId);
- if (WindowState.MAXIMIZED.equals(windowNS.getWindowState()))
- {
- return windowId;
- }
- }
- }
-
- //
- return null;
- }
-
- public PagePortletControllerContext getPortletControllerContext()
- {
- return portletControllerContext;
- }
-
- public String nextId()
- {
- return "" + count++;
- }
-}
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageParamTag.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -87,11 +87,8 @@
this.frozen = frozen;
}
- public void internalDoTag() throws JspException, IOException
+ public void doRenderTag(PortalRenderResponse renderResponse) throws JspException,
IOException
{
- PortalRenderResponse renderResponse = getPortalResponse();
-
- //
if (renderResponse.isPageStateModifiable())
{
QName name = new QName(namespaceURI, localName);
@@ -103,4 +100,8 @@
}
}
}
+
+ public void doActionTag() throws JspException, IOException
+ {
+ }
}
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageTag.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.test.jsp.taglib;
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
+import org.jboss.portal.portlet.test.jsp.PortalResponse;
import javax.servlet.jsp.JspException;
import javax.xml.namespace.QName;
@@ -38,7 +39,7 @@
enum Status
{
- INACTIVE, ACTIVE, SUSPENDED
+ ACTIVE, SUSPENDED
}
/** . */
@@ -51,49 +52,25 @@
String content;
/** . */
- Status status = Status.INACTIVE;
+ Status status = Status.ACTIVE;
- public int doStartTag() throws JspException
+ public int doStartRenderTag(PortalRenderResponse renderResponse) throws JspException
{
- if (status == Status.INACTIVE)
- {
- PortalRenderResponse renderResponse = getPortalResponse();
+ maximizedId = renderResponse.getMaximizedWindowId();
- //
- status = Status.ACTIVE;
-
- //
- maximizedId = renderResponse.getMaximizedWindowId();
-
- //
- if (maximizedId != null)
- {
- return EVAL_BODY_BUFFERED;
- }
- else
- {
- return EVAL_BODY_INCLUDE;
- }
+ //
+ if (maximizedId != null)
+ {
+ return EVAL_BODY_BUFFERED;
}
else
{
- return SKIP_BODY;
+ return EVAL_BODY_INCLUDE;
}
}
- public int doEndTag() throws JspException
+ public int doEndRenderTag(PortalRenderResponse renderResponse) throws JspException
{
- switch (status)
- {
- case SUSPENDED:
- break;
- case INACTIVE:
- break;
- case ACTIVE:
- status = Status.INACTIVE;
- }
-
- //
if (maximizedId != null)
{
try
@@ -109,4 +86,14 @@
//
return EVAL_PAGE;
}
+
+ public int doStartTag(PortalResponse portalResponse) throws JspException
+ {
+ return EVAL_BODY_INCLUDE;
+ }
+
+ public int doEndTag(PortalResponse portalResponse) throws JspException
+ {
+ return EVAL_PAGE;
+ }
}
Modified:
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 2008-02-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
+import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
+
import javax.servlet.jsp.tagext.SimpleTagSupport;
import javax.servlet.jsp.JspException;
import java.io.IOException;
@@ -59,7 +61,7 @@
this.value = value;
}
- public void internalDoTag() throws JspException, IOException
+ public void doRenderTag(PortalRenderResponse renderResponse) 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/PortalBodyTagSupport.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortalBodyTagSupport.java 2008-02-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortalBodyTagSupport.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -23,6 +23,9 @@
package org.jboss.portal.portlet.test.jsp.taglib;
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
+import org.jboss.portal.portlet.test.jsp.PortalActionResponse;
+import org.jboss.portal.portlet.test.jsp.PortalResponse;
+import org.jboss.portal.common.NotYetImplemented;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
@@ -33,34 +36,74 @@
*/
public class PortalBodyTagSupport extends BodyTagSupport
{
- protected final PortalRenderResponse getPortalResponse()
+
+ private PortalResponse getPortalResponse()
{
- return (PortalRenderResponse)pageContext.getResponse();
+ return (PortalResponse)pageContext.getResponse();
}
- public int doStartTag() throws JspException
+ public final int doStartTag() throws JspException
{
+ return doStartTag(getPortalResponse());
+ }
+
+ public final int doEndTag() throws JspException
+ {
+ return doEndTag(getPortalResponse());
+ }
+
+ public int doStartTag(PortalResponse portalResponse) throws JspException
+ {
PageTag pageTag = (PageTag)findAncestorWithClass(this, PageTag.class);
//
+ if (pageTag == null && this instanceof PageTag)
+ {
+ pageTag = (PageTag)this;
+
+ //
+ pageTag.status = PageTag.Status.ACTIVE;
+ }
+
+ //
if (pageTag == null || pageTag.status != PageTag.Status.ACTIVE)
{
return SKIP_BODY;
}
else
{
- return internalDoStartTag();
+ if (portalResponse instanceof PortalActionResponse)
+ {
+ return doStartActionTag((PortalActionResponse)portalResponse);
+ }
+ else
+ {
+ return doStartRenderTag((PortalRenderResponse)portalResponse);
+ }
}
}
- public int doEndTag() throws JspException
+ public int doEndTag(PortalResponse portalResponse) throws JspException
{
PageTag pageTag = (PageTag)findAncestorWithClass(this, PageTag.class);
//
+ if (pageTag == null && this instanceof PageTag)
+ {
+ pageTag = (PageTag)this;
+ }
+
+ //
if (pageTag != null && pageTag.status == PageTag.Status.ACTIVE)
{
- return internalDoEndTag();
+ if (portalResponse instanceof PortalActionResponse)
+ {
+ return doEndActionTag((PortalActionResponse)portalResponse);
+ }
+ else
+ {
+ return doEndRenderTag((PortalRenderResponse)portalResponse);
+ }
}
else
{
@@ -68,12 +111,22 @@
}
}
- public int internalDoStartTag() throws JspException
+ public int doStartActionTag(PortalActionResponse actionResponse) throws JspException
{
+ throw new NotYetImplemented();
+ }
+
+ public int doEndActionTag(PortalActionResponse actionResponse) throws JspException
+ {
+ throw new NotYetImplemented();
+ }
+
+ public int doStartRenderTag(PortalRenderResponse renderResponse) throws JspException
+ {
return super.doStartTag();
}
- public int internalDoEndTag() throws JspException
+ public int doEndRenderTag(PortalRenderResponse renderResponse) throws JspException
{
return super.doEndTag();
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortalSimpleTagSupport.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortalSimpleTagSupport.java 2008-02-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortalSimpleTagSupport.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -23,6 +23,9 @@
package org.jboss.portal.portlet.test.jsp.taglib;
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
+import org.jboss.portal.portlet.test.jsp.PortalResponse;
+import org.jboss.portal.portlet.test.jsp.PortalActionResponse;
+import org.jboss.portal.common.NotYetImplemented;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import javax.servlet.jsp.PageContext;
@@ -35,25 +38,37 @@
*/
public class PortalSimpleTagSupport extends SimpleTagSupport
{
- protected final PortalRenderResponse getPortalResponse()
+ private PortalResponse getPortalResponse()
{
PageContext pageContext = (PageContext)getJspContext();
- return (PortalRenderResponse)pageContext.getResponse();
+ return (PortalResponse)pageContext.getResponse();
}
- public void doTag() throws JspException, IOException
+ public final void doTag() throws JspException, IOException
{
PageTag pageTag = (PageTag)findAncestorWithClass(this, PageTag.class);
//
if (pageTag != null && pageTag.status == PageTag.Status.ACTIVE)
{
- internalDoTag();
+ if (getPortalResponse() instanceof PortalActionResponse)
+ {
+ doActionTag();
+ }
+ else
+ {
+ doRenderTag((PortalRenderResponse)getPortalResponse());
+ }
}
}
- public void internalDoTag() throws JspException, IOException
+ public void doActionTag() throws JspException, IOException
{
+ throw new NotYetImplemented();
+ }
+
+ public void doRenderTag(PortalRenderResponse renderResponse) throws JspException,
IOException
+ {
super.doTag();
}
}
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletMarkupTag.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -39,10 +39,8 @@
*/
public class PortletMarkupTag extends PortalSimpleTagSupport
{
- public void internalDoTag() throws JspException, IOException
+ public void doRenderTag(PortalRenderResponse renderResponse) throws JspException,
IOException
{
- PortalRenderResponse resp = getPortalResponse();
-
PortletTag portletTag = (PortletTag)SimpleTagSupport.findAncestorWithClass(this,
PortletTag.class);
PortletInvocationResponse portletResp = portletTag.result.getResponse();
@@ -55,9 +53,9 @@
{
FragmentResponse fragment = (FragmentResponse)portletResp;
WindowNavigationalState windowNS = null;
- if (resp.getPageState() != null)
+ if (renderResponse.getPageState() != null)
{
- windowNS =
resp.getPageState().getWindowNavigationalState(portletTag.result.getWindowId());
+ windowNS =
renderResponse.getPageState().getWindowNavigationalState(portletTag.result.getWindowId());
}
if (windowNS == null ||
!windowNS.getWindowState().equals(WindowState.MINIMIZED))
{
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -23,7 +23,8 @@
package org.jboss.portal.portlet.test.jsp.taglib;
import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
-import org.jboss.portal.portlet.test.jsp.PagePortletControllerContext;
+import org.jboss.portal.portlet.test.jsp.PortalActionResponse;
+import org.jboss.portal.portlet.test.jsp.PortalResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
@@ -78,7 +79,8 @@
private Set<Mode> supportedModes;
private Mode initialMode;
private PageTag pageTag;
- private PortalRenderResponse renderResponse;
+ private Portlet portlet;
+ private String windowId;
/** . */
PortletResult result;
@@ -143,7 +145,7 @@
this.errorPageAttr = errorPage;
}
- private void initState()
+ private void initState(PortalResponse portalResponse)
{
//
Set<Mode> supportedModes = new LinkedHashSet<Mode>();
@@ -183,11 +185,22 @@
}
//
+ Portlet portlet = portalResponse.findPortlet(applicationNameAttr, nameAttr);
+
+ //
+ String windowId = null;
+ if (portlet != null)
+ {
+ windowId = portlet.getContext().getId() + "." +
portalResponse.nextId();
+ }
+
+ //
this.initialMode = initialMode;
this.supportedModes = supportedModes;
this.supportedWindowStates = supportedWindowStates;
this.pageTag = (PageTag)findAncestorWithClass(this, PageTag.class);
- this.renderResponse = getPortalResponse();
+ this.portlet = portlet;
+ this.windowId = windowId;
}
private void destroyState()
@@ -196,37 +209,51 @@
this.supportedModes = null;
this.supportedWindowStates = null;
this.pageTag = null;
- this.renderResponse = null;
+ this.portlet = null;
+ this.windowId = null;
}
- public int internalDoStartTag() throws JspException
+ public int doStartActionTag(PortalActionResponse actionResponse) throws JspException
{
- initState();
+ initState(actionResponse);
//
- PagePortletControllerContext context =
renderResponse.getPortletControllerContext();
+ if (portlet != null)
+ {
+ actionResponse.addWindow(windowId, portlet);
+ }
//
- Portlet portlet = context.findPortlet(applicationNameAttr, nameAttr);
+ return SKIP_BODY;
+ }
+ public int doEndActionTag(PortalActionResponse actionResponse) throws JspException
+ {
+ destroyState();
+
//
+ return EVAL_PAGE;
+ }
+
+ public int doStartRenderTag(PortalRenderResponse renderResponse) throws JspException
+ {
+ initState(renderResponse);
+
+ //
if (portlet == null)
{
- handleError(null, Constants.NOT_FOUND, null, null);
+ handleError(renderResponse, Constants.NOT_FOUND, null, null);
// We cannot show an absent portlet, no meta data
return SKIP_BODY;
}
else
{
- String windowId = portlet.getContext().getId() + "." +
renderResponse.nextId();
-
- //
if (pageTag.maximizedId != null)
{
if (windowId.equals(pageTag.maximizedId))
{
- return render(portlet, windowId, EVAL_BODY_BUFFERED);
+ return render(renderResponse, EVAL_BODY_BUFFERED);
}
else
{
@@ -235,12 +262,12 @@
}
else
{
- return render(portlet, windowId, EVAL_BODY_INCLUDE);
+ return render(renderResponse, EVAL_BODY_INCLUDE);
}
}
}
- public int internalDoEndTag() throws JspException
+ public int doEndRenderTag(PortalRenderResponse renderResponse) throws JspException
{
if (bodyContent != null)
{
@@ -254,7 +281,7 @@
return EVAL_PAGE;
}
- public int render(Portlet portlet, String windowId, int rt)
+ public int render(PortalRenderResponse renderResponse, int rt)
{
try
{
@@ -280,21 +307,21 @@
ErrorResponse error = (ErrorResponse)portletResponse;
//
- handleError(windowId, Constants.PORTLET_ERROR, error.getCause(),
error.getMessage());
+ handleError(renderResponse, Constants.PORTLET_ERROR, error.getCause(),
error.getMessage());
//
return SKIP_BODY;
}
else if (portletResponse instanceof UnavailableResponse)
{
- handleError(windowId, Constants.UNAVAILABLE, null, null);
+ handleError(renderResponse, Constants.UNAVAILABLE, null, null);
//
return SKIP_BODY;
}
else
{
- handleError(windowId, Constants.INTERNAL_ERROR, null, null);
+ handleError(renderResponse, Constants.INTERNAL_ERROR, null, null);
//
return SKIP_BODY;
@@ -302,14 +329,14 @@
}
catch (PortletInvokerException e)
{
- handleError(windowId, Constants.INTERNAL_ERROR, e, e.getMessage());
+ handleError(renderResponse, Constants.INTERNAL_ERROR, e, e.getMessage());
//
return SKIP_BODY;
}
}
- private void handleError(String windowId, String errorStatus, Throwable cause, String
message)
+ private void handleError(PortalRenderResponse renderResponse, String errorStatus,
Throwable cause, String message)
{
if (errorPageAttr != null)
{
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTitleTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTitleTag.java 2008-02-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTitleTag.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -24,6 +24,7 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.test.jsp.PortalRenderResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
@@ -37,7 +38,7 @@
public class PortletTitleTag extends PortalSimpleTagSupport
{
- public void internalDoTag() throws JspException, IOException
+ public void doRenderTag(PortalRenderResponse renderResponse) throws JspException,
IOException
{
PortletTag portletTag = (PortletTag)SimpleTagSupport.findAncestorWithClass(this,
PortletTag.class);
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-09
14:44:32 UTC (rev 9900)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-09
16:11:00 UTC (rev 9901)
@@ -70,14 +70,13 @@
this.windowStateValue = windowState;
}
- public int internalDoStartTag() throws JspException
+ public int doStartRenderTag(PortalRenderResponse renderResponse) throws JspException
{
return EVAL_BODY_BUFFERED;
}
- public int internalDoEndTag() throws JspException
+ public int doEndRenderTag(PortalRenderResponse renderResponse) throws JspException
{
- PortalRenderResponse renderResponse = getPortalResponse();
PagePortletControllerContext context =
renderResponse.getPortletControllerContext();
PortletTag portletTag = (PortletTag)SimpleTagSupport.findAncestorWithClass(this,
PortletTag.class);