JBoss Portal SVN: r9819 - 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-06 19:07:31 -0500 (Wed, 06 Feb 2008)
New Revision: 9819
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java
Log:
removed what idea should have removed
Deleted: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-06 23:49:49 UTC (rev 9818)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-07 00:07:31 UTC (rev 9819)
@@ -1,221 +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.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.PortletChunk;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-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.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.common.io.IOTools;
-
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-public class ControllerServlet extends HttpServlet
-{
-
- protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- {
- try
- {
- _service(req, resp);
- }
- catch (ClassNotFoundException e)
- {
- throw new ServletException(e);
- }
- }
-
- protected void _service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, ClassNotFoundException
- {
- PortletInvoker invoker = (PortletInvoker)getServletContext().getAttribute("ConsumerPortletInvoker");
-
- //
- PagePortletControllerContext context = new PagePortletControllerContext(req, resp, getServletContext(), invoker);
-
- //
- PageNavigationalState pageState = null;
- if (context.getRequest() != null)
- {
- ControllerResponse controllerResponse;
- try
- {
- controllerResponse = new PortletController().process(context.getRequest());
- }
- catch (PortletInvokerException e)
- {
- throw new ServletException(e);
- }
-
- //
- if (controllerResponse instanceof PageUpdateResponse)
- {
- PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
- pageState = pageUpdate.getPageState();
- }
- else if (controllerResponse instanceof ResourceResponse)
- {
- ResourceResponse resourceResponse = (ResourceResponse)controllerResponse;
- PortletInvocationResponse pir = resourceResponse.response;
-
- //
- if (pir instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)pir;
-
- //
- if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
- {
- resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
- }
- else
- {
- String contentType = fragment.getContentType();
- if (contentType != null)
- {
- resp.setContentType(contentType);
- }
-
- //
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
- {
- ServletOutputStream out = null;
- try
- {
- out = resp.getOutputStream();
- out.write(fragment.getBytes().toByteArray());
- }
- finally
- {
- IOTools.safeClose(out);
- }
- }
- else
- {
- Writer writer = null;
- try
- {
- writer = resp.getWriter();
- writer.write(fragment.getChars().toString());
- }
- finally
- {
- writer.close();
- }
- }
- }
- }
- else
- {
- // todo
- }
- }
- else
- {
- // todo
- }
- }
-
- //
- Page page = context.getPage();
-
- //
- Map<String, PortletInvocationResponse> responses = page.render(context, pageState);
-
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
- int count = 0;
- for (Chunk chunk : page.getChunks())
- {
- if (chunk instanceof BytesChunk)
- {
- BytesChunk bytesChunk = (BytesChunk)chunk;
- writer.write(new String(bytesChunk.getBytes()));
- }
- else if (chunk instanceof CharsChunk)
- {
- CharsChunk bytesChunk = (CharsChunk)chunk;
- writer.write(bytesChunk.getChars());
- }
- else if (chunk instanceof PortletChunk)
- {
- PortletChunk portletChunk = (PortletChunk)chunk;
- String windowId = "" + count++;
-
- PortletInvocationResponse response = responses.get(windowId);
- if (response != null)
- {
- if (response instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)response;
- 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);
- }
- }
- else
- {
- writer.write(response.getClass().getSimpleName() + "[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
- }
- }
- else
- {
- writer.write("Empty[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
- }
- }
- }
- writer.close();
- }
-}
16 years, 4 months
JBoss Portal SVN: r9818 - modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 18:49:49 -0500 (Wed, 06 Feb 2008)
New Revision: 9818
Modified:
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml
Log:
crap I suck at this time of the day
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml 2008-02-06 23:48:20 UTC (rev 9817)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml 2008-02-06 23:49:49 UTC (rev 9818)
@@ -32,7 +32,7 @@
</filter>
<filter-mapping>
<filter-name>ControllerFilter</filter-name>
- <url-pattern>/*.jsp</url-pattern>
+ <url-pattern>*.jsp</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
16 years, 4 months
JBoss Portal SVN: r9817 - modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 18:48:20 -0500 (Wed, 06 Feb 2008)
New Revision: 9817
Modified:
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml
Log:
fitler only jsps
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml 2008-02-06 23:47:22 UTC (rev 9816)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml 2008-02-06 23:48:20 UTC (rev 9817)
@@ -32,7 +32,7 @@
</filter>
<filter-mapping>
<filter-name>ControllerFilter</filter-name>
- <url-pattern>/*</url-pattern>
+ <url-pattern>/*.jsp</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
16 years, 4 months
JBoss Portal SVN: r9816 - in modules/portlet/trunk/test/src: main/java/org/jboss/portal/portlet/test/controller and 2 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 18:47:22 -0500 (Wed, 06 Feb 2008)
New Revision: 9816
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
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/jsp/Page.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml
Log:
make the controller as a filter as it is more powerful that way
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-06 22:58:00 UTC (rev 9815)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/URLParameterConstants.java 2008-02-06 23:47:22 UTC (rev 9816)
@@ -39,6 +39,9 @@
*/
public static final String LIFECYCLE_TYPE = "type";
+ /** The window id. */
+ public static final String WINDOW_ID = "windowid";
+
/** The portlet mode. */
public static final String MODE = "mode";
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-06 22:58:00 UTC (rev 9815)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-06 23:47:22 UTC (rev 9816)
@@ -30,7 +30,6 @@
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.portlet.ContainerURL;
import org.jboss.portal.portlet.ParametersStateString;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
@@ -61,7 +60,6 @@
import org.jboss.portal.portlet.invocation.ResourceInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.spi.PortletInvocationContext;
-import org.jboss.portal.portlet.test.StringCodec;
import static org.jboss.portal.portlet.test.URLParameterConstants.*;
import org.jboss.portal.web.Body;
import org.jboss.portal.web.IllegalRequestException;
@@ -120,13 +118,12 @@
// The request decoded if not null
ControllerRequest request = null;
+ // Get the window id
+ String windowId = req.getParameter(WINDOW_ID);
+
// Process
- String pathInfo = req.getPathInfo();
- if (pathInfo != null && pathInfo.startsWith("/") && pathInfo.length() > 1)
+ if (windowId != null)
{
- // Get the target portlet
- String targetId = StringCodec.decode(pathInfo.substring(1));
-
// Helper
WebRequest ri = new WebRequest(req);
@@ -186,7 +183,7 @@
case FULL:
request = new FullScopedCacheablePortletResourceRequest(
this,
- targetId,
+ windowId,
resourceId,
resourceState,
formParameters);
@@ -194,7 +191,7 @@
case PORTLET:
request = new PortletScopedPortletResourceRequest(
this,
- targetId,
+ windowId,
resourceId,
resourceState,
formParameters,
@@ -203,7 +200,7 @@
case PAGE:
request = new PageScopedFullPortletResourceRequest(
this,
- targetId,
+ windowId,
resourceId,
resourceState,
formParameters,
@@ -228,7 +225,7 @@
//
request = new PortletActionRequest(
this,
- targetId,
+ windowId,
interactionState,
formParameters,
windowNavigationalState,
@@ -241,7 +238,7 @@
//
request = new PortletRenderRequest(
this,
- targetId,
+ windowId,
windowNavigationalState,
publicNavigationalStateChanges,
pageState);
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-06 22:58:00 UTC (rev 9815)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-06 23:47:22 UTC (rev 9816)
@@ -91,13 +91,20 @@
buffer.append(Integer.toString(clientReq.getServerPort()));
buffer.append(clientReq.getContextPath());
buffer.append(clientReq.getServletPath());
- buffer.append('/');
- buffer.append(StringCodec.encode(windowId));
//
+ if (clientReq.getPathInfo() != null)
+ {
+ buffer.append(clientReq.getPathInfo());
+ }
+
+ //
Map<String, String> parameters = new HashMap<String, String>();
//
+ parameters.put(WINDOW_ID, windowId);
+
+ //
String type;
if (containerURL instanceof ActionURL)
{
Copied: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java (from rev 9815, modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java)
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-06 23:47:22 UTC (rev 9816)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * 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.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.PortletChunk;
+import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
+import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+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.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.common.io.IOTools;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletContext;
+import java.io.IOException;
+import java.io.Writer;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ControllerFilter implements Filter
+{
+
+ /** . */
+ private FilterConfig config;
+
+ private ServletContext getServletContext()
+ {
+ return config.getServletContext();
+ }
+
+ public void init(FilterConfig config) throws ServletException
+ {
+ this.config = config;
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException
+ {
+ doFilter((HttpServletRequest)req, (HttpServletResponse)resp, chain);
+ }
+
+ public void doFilter(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException
+ {
+ BufferingResponse bufferingResponse = new BufferingResponse(resp);
+
+ //
+ chain.doFilter(req, bufferingResponse);
+
+ //
+ ResponseBuffer buffer = bufferingResponse.getBuffer();
+ buffer.close();
+
+ //
+ try
+ {
+ service(req, resp, buffer);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ServletException(e);
+ }
+ }
+
+ public void destroy()
+ {
+ this.config = null;
+ }
+
+ protected void service(HttpServletRequest req, HttpServletResponse resp, ResponseBuffer buffer) throws ServletException, IOException, ClassNotFoundException
+ {
+ PortletInvoker invoker = (PortletInvoker)getServletContext().getAttribute("ConsumerPortletInvoker");
+
+ //
+ PagePortletControllerContext context = new PagePortletControllerContext(
+ req,
+ resp,
+ getServletContext(),
+ invoker,
+ buffer);
+
+ //
+ PageNavigationalState pageState = null;
+ if (context.getRequest() != null)
+ {
+ ControllerResponse controllerResponse;
+ try
+ {
+ controllerResponse = new PortletController().process(context.getRequest());
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new ServletException(e);
+ }
+
+ //
+ if (controllerResponse instanceof PageUpdateResponse)
+ {
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
+ pageState = pageUpdate.getPageState();
+ }
+ else if (controllerResponse instanceof ResourceResponse)
+ {
+ ResourceResponse resourceResponse = (ResourceResponse)controllerResponse;
+ PortletInvocationResponse pir = resourceResponse.response;
+
+ //
+ if (pir instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)pir;
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
+ {
+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ }
+ else
+ {
+ String contentType = fragment.getContentType();
+ if (contentType != null)
+ {
+ resp.setContentType(contentType);
+ }
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ ServletOutputStream out = null;
+ try
+ {
+ out = resp.getOutputStream();
+ out.write(fragment.getBytes().toByteArray());
+ }
+ finally
+ {
+ IOTools.safeClose(out);
+ }
+ }
+ else
+ {
+ Writer writer = null;
+ try
+ {
+ writer = resp.getWriter();
+ writer.write(fragment.getChars().toString());
+ }
+ finally
+ {
+ writer.close();
+ }
+ }
+ }
+ }
+ else
+ {
+ // todo
+ }
+ }
+ else
+ {
+ // todo
+ }
+ }
+
+ //
+ Page page = context.getPage();
+
+ //
+ Map<String, PortletInvocationResponse> responses = page.render(context, pageState);
+
+ //
+ OutputStream out = resp.getOutputStream();
+ OutputStreamWriter writer = new OutputStreamWriter(out);
+
+ //
+ int count = 0;
+ for (Chunk chunk : page.getChunks())
+ {
+ if (chunk instanceof BytesChunk)
+ {
+ BytesChunk bytesChunk = (BytesChunk)chunk;
+ out.write(bytesChunk.getBytes());
+ out.flush();
+ }
+ else if (chunk instanceof CharsChunk)
+ {
+ CharsChunk bytesChunk = (CharsChunk)chunk;
+ writer.write(bytesChunk.getChars());
+ writer.flush();
+ }
+ else if (chunk instanceof PortletChunk)
+ {
+ PortletChunk portletChunk = (PortletChunk)chunk;
+ String windowId = "" + count++;
+
+ PortletInvocationResponse response = responses.get(windowId);
+ if (response != null)
+ {
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ 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
+ {
+ writer.write(response.getClass().getSimpleName() + "[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
+ writer.flush();
+ }
+ }
+ else
+ {
+ writer.write("Empty[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
+ writer.flush();
+ }
+ }
+ }
+ 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-06 22:58:00 UTC (rev 9815)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-06 23:47:22 UTC (rev 9816)
@@ -26,13 +26,7 @@
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.PortletChunk;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.info.PortletInfo;
-import javax.servlet.ServletException;
-import javax.xml.namespace.QName;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
@@ -45,22 +39,15 @@
{
/** . */
- public static final QName PAGE_ID_NAME = new QName("urn:jboss-portlet-container", "pageid");
-
- /** . */
private Map<String, Window> windows;
/** . */
private List<Chunk> chunks;
- /** . */
- private final String pageId;
-
- public Page(List<Chunk> chunks, Map<String, Window> windows, String pageId)
+ public Page(List<Chunk> chunks, Map<String, Window> windows)
{
this.chunks = chunks;
this.windows = windows;
- this.pageId = pageId;
}
public List<Chunk> getChunks()
@@ -78,7 +65,6 @@
if (pageState == null)
{
pageState = context.getStateControllerContext().createPageState();
- pageState.setPublicNavigationalState(PAGE_ID_NAME, new String[]{pageId});
}
//
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-06 22:58:00 UTC (rev 9815)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-06 23:47:22 UTC (rev 9816)
@@ -33,9 +33,6 @@
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.controller.event.EventControllerContext;
import org.jboss.portal.portlet.controller.impl.event.EventControllerContextImpl;
-import org.jboss.portal.portlet.controller.request.PortletRequest;
-import org.jboss.portal.portlet.controller.request.PageScopedFullPortletResourceRequest;
-import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.web.IllegalRequestException;
@@ -44,7 +41,6 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
-import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
@@ -69,53 +65,12 @@
HttpServletRequest req,
HttpServletResponse resp,
ServletContext servletContext,
- PortletInvoker invoker)
+ PortletInvoker invoker,
+ ResponseBuffer buffer)
throws IllegalRequestException, IOException, ClassNotFoundException, ServletException
{
super(req, resp, servletContext);
-
- //
- PageNavigationalState pageState = null;
- if (getRequest() instanceof PortletRequest)
- {
- PortletRequest request = (PortletRequest)getRequest();
- pageState = request.getPageState();
- }
- else if (getRequest() instanceof PageScopedFullPortletResourceRequest)
- {
- PageScopedFullPortletResourceRequest request = (PageScopedFullPortletResourceRequest)getRequest();
- pageState = request.getPageState();
- }
-
- //
- String pageId = null;
- if (pageState != null)
- {
- String[] values = pageState.getPublicNavigationalState(Page.PAGE_ID_NAME);
- if (values != null && values.length > 0)
- {
- pageId = values[0];
- }
- }
- if (pageId == null)
- {
- pageId = "/index.jsp";
- }
-
- //
- RequestDispatcher dispatcher = req.getRequestDispatcher(pageId);
-
- //
- BufferingResponse bufferingResponse = new BufferingResponse(resp);
-
- //
- dispatcher.include(req, bufferingResponse);
-
- //
- ResponseBuffer buffer = bufferingResponse.getBuffer();
- buffer.close();
-
// Collect portlets to create the page
int counter = 0;
Map<String, Window> windows = new HashMap<String, Window>();
@@ -150,7 +105,7 @@
}
//
- this.page = new Page(buffer.getChunks(), windows, pageId);
+ this.page = new Page(buffer.getChunks(), windows);
this.invoker = invoker;
this.eventControllerContext = new EventControllerContextImpl(invoker);
}
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml 2008-02-06 22:58:00 UTC (rev 9815)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/web.xml 2008-02-06 23:47:22 UTC (rev 9816)
@@ -26,6 +26,14 @@
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
+ <filter>
+ <filter-name>ControllerFilter</filter-name>
+ <filter-class>org.jboss.portal.portlet.test.jsp.ControllerFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ControllerFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
<listener>
<listener-class>org.jboss.portal.common.mc.bootstrap.WebBootstrap</listener-class>
</listener>
@@ -38,16 +46,8 @@
<servlet-name>PortalServlet</servlet-name>
<servlet-class>org.jboss.portal.simple.SimplePortalServlet</servlet-class>
</servlet>
- <servlet>
- <servlet-name>ControllerServlet</servlet-name>
- <servlet-class>org.jboss.portal.portlet.test.jsp.ControllerServlet</servlet-class>
- </servlet>
<servlet-mapping>
<servlet-name>PortalServlet</servlet-name>
- <url-pattern>/</url-pattern>
+ <url-pattern>/simple</url-pattern>
</servlet-mapping>
- <servlet-mapping>
- <servlet-name>ControllerServlet</servlet-name>
- <url-pattern>/jsp/*</url-pattern>
- </servlet-mapping>
</web-app>
16 years, 4 months
JBoss Portal SVN: r9815 - in modules/portlet/trunk/test/src: test/resources/simple-portal-war and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 17:58:00 -0500 (Wed, 06 Feb 2008)
New Revision: 9815
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java
modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
Log:
implement resource serving in portal jsp
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-06 22:49:03 UTC (rev 9814)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-06 22:58:00 UTC (rev 9815)
@@ -33,14 +33,18 @@
import org.jboss.portal.portlet.controller.PortletController;
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.common.io.IOTools;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.io.Writer;
import java.util.Map;
/**
@@ -89,6 +93,63 @@
PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
pageState = pageUpdate.getPageState();
}
+ else if (controllerResponse instanceof ResourceResponse)
+ {
+ ResourceResponse resourceResponse = (ResourceResponse)controllerResponse;
+ PortletInvocationResponse pir = resourceResponse.response;
+
+ //
+ if (pir instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)pir;
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_EMPTY)
+ {
+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ }
+ else
+ {
+ String contentType = fragment.getContentType();
+ if (contentType != null)
+ {
+ resp.setContentType(contentType);
+ }
+
+ //
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ ServletOutputStream out = null;
+ try
+ {
+ out = resp.getOutputStream();
+ out.write(fragment.getBytes().toByteArray());
+ }
+ finally
+ {
+ IOTools.safeClose(out);
+ }
+ }
+ else
+ {
+ Writer writer = null;
+ try
+ {
+ writer = resp.getWriter();
+ writer.write(fragment.getChars().toString());
+ }
+ finally
+ {
+ writer.close();
+ }
+ }
+ }
+ }
+ else
+ {
+ // todo
+ }
+ }
else
{
// todo
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-06 22:49:03 UTC (rev 9814)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-06 22:58:00 UTC (rev 9815)
@@ -13,6 +13,10 @@
name="GoogleMap"
applicationName="google-map-portlet"/>
THREE
+ <portal:portlet
+ name="RemoteControl"
+ applicationName="remotecontrol-portlet"/>
+ FOUR
</portal:page>
</body>
</html>
16 years, 4 months
JBoss Portal SVN: r9814 - modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 17:49:03 -0500 (Wed, 06 Feb 2008)
New Revision: 9814
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageTag.java
Log:
removed sysout
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-06 22:48:16 UTC (rev 9813)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PageTag.java 2008-02-06 22:49:03 UTC (rev 9814)
@@ -34,16 +34,11 @@
public int doStartTag() throws JspException
{
- System.out.println("START");
-
-
return EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspException
{
- System.out.println("END");
-
return EVAL_PAGE;
}
}
16 years, 4 months
JBoss Portal SVN: r9813 - in modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet: controller/state and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 17:48:16 -0500 (Wed, 06 Feb 2008)
New Revision: 9813
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/state/PageNavigationalState.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.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:
stuff the page id in the public NS
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-06 22:15:06 UTC (rev 9812)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/impl/state/PageNavigationalStateImpl.java 2008-02-06 22:48:16 UTC (rev 9813)
@@ -104,6 +104,11 @@
return publicNavigationalState;
}
+ public String[] getPublicNavigationalState(QName name)
+ {
+ return page.get(name).clone();
+ }
+
public void setWindowNavigationalState(String windowId, WindowNavigationalState windowState) throws UnsupportedOperationException
{
throw new UnsupportedOperationException();
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-06 22:15:06 UTC (rev 9812)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/controller/state/PageNavigationalState.java 2008-02-06 22:48:16 UTC (rev 9813)
@@ -24,6 +24,7 @@
import org.jboss.portal.common.util.ParameterMap;
+import javax.xml.namespace.QName;
import java.util.Map;
/**
@@ -74,4 +75,10 @@
* @throws UnsupportedOperationException if the page state is read only
*/
void setPublicNavigationalState(String windowId, Map<String, String[]> update) throws UnsupportedOperationException;
+
+ String[] getPublicNavigationalState(QName name);
+
+ void setPublicNavigationalState(QName name, String[] value);
+
+ void removePublicNavigationalState(QName name);
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-06 22:15:06 UTC (rev 9812)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-06 22:48:16 UTC (rev 9813)
@@ -22,14 +22,11 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp;
-import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
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.PortletChunk;
-import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
@@ -37,13 +34,11 @@
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
-import org.jboss.portal.portlet.info.PortletInfo;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
-import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
@@ -72,55 +67,9 @@
PortletInvoker invoker = (PortletInvoker)getServletContext().getAttribute("ConsumerPortletInvoker");
//
- RequestDispatcher dispatcher = req.getRequestDispatcher("/index.jsp");
+ PagePortletControllerContext context = new PagePortletControllerContext(req, resp, getServletContext(), invoker);
//
- BufferingResponse bufferingResponse = new BufferingResponse(resp);
-
- //
- dispatcher.include(req, bufferingResponse);
-
- //
- ResponseBuffer buffer = bufferingResponse.getBuffer();
- buffer.close();
-
- // Collect portlets to create the page
- int counter = 0;
- Page page = new Page();
- for (Chunk chunk : buffer.getChunks())
- {
- if (chunk instanceof PortletChunk)
- {
- PortletChunk portletChunk = (PortletChunk)chunk;
- String windowId = "" + counter++;
-
- //
- try
- {
- for (Portlet portlet : invoker.getPortlets())
- {
- PortletInfo portletInfo = portlet.getInfo();
- String portletName = portletInfo.getName();
- String applicationName = portletInfo.getApplicationName();
-
- //
- if (applicationName.equals(portletChunk.getApplicationName()) && portletName.equals(portletChunk.getPortletName()))
- {
- page.addWindow(new Window(windowId, portlet));
- }
- }
- }
- catch (PortletInvokerException e)
- {
- throw new ServletException(e);
- }
- }
- }
-
- //
- PagePortletControllerContext context = new PagePortletControllerContext(req, resp, getServletContext(), page, invoker);
-
- //
PageNavigationalState pageState = null;
if (context.getRequest() != null)
{
@@ -140,20 +89,23 @@
PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
pageState = pageUpdate.getPageState();
}
+ else
+ {
+ // todo
+ }
}
- else
- {
- pageState = context.getStateControllerContext().createPageState();
- }
//
+ Page page = context.getPage();
+
+ //
Map<String, PortletInvocationResponse> responses = page.render(context, pageState);
//
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
int count = 0;
- for (Chunk chunk : buffer.getChunks())
+ for (Chunk chunk : page.getChunks())
{
if (chunk instanceof BytesChunk)
{
@@ -203,8 +155,6 @@
}
}
}
-
- //
writer.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-06 22:15:06 UTC (rev 9812)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-06 22:48:16 UTC (rev 9813)
@@ -25,9 +25,17 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
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.PortletChunk;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.PortletInfo;
+import javax.servlet.ServletException;
+import javax.xml.namespace.QName;
import java.util.Map;
import java.util.HashMap;
+import java.util.List;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -37,16 +45,27 @@
{
/** . */
+ public static final QName PAGE_ID_NAME = new QName("urn:jboss-portlet-container", "pageid");
+
+ /** . */
private Map<String, Window> windows;
- public Page()
+ /** . */
+ private List<Chunk> chunks;
+
+ /** . */
+ private final String pageId;
+
+ public Page(List<Chunk> chunks, Map<String, Window> windows, String pageId)
{
- this.windows = new HashMap<String, Window>();
+ this.chunks = chunks;
+ this.windows = windows;
+ this.pageId = pageId;
}
- public void addWindow(Window window)
+ public List<Chunk> getChunks()
{
- windows.put(window.getId(), window);
+ return chunks;
}
public Window getWindow(String windowId)
@@ -56,6 +75,13 @@
public Map<String, PortletInvocationResponse> render(PortletControllerContext context, PageNavigationalState pageState)
{
+ if (pageState == null)
+ {
+ pageState = context.getStateControllerContext().createPageState();
+ pageState.setPublicNavigationalState(PAGE_ID_NAME, new String[]{pageId});
+ }
+
+ //
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-06 22:15:06 UTC (rev 9812)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-06 22:48:16 UTC (rev 9813)
@@ -23,11 +23,19 @@
package org.jboss.portal.portlet.test.jsp;
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.PortletChunk;
+import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
+import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
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.controller.impl.event.EventControllerContextImpl;
+import org.jboss.portal.portlet.controller.request.PortletRequest;
+import org.jboss.portal.portlet.controller.request.PageScopedFullPortletResourceRequest;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.web.IllegalRequestException;
@@ -35,7 +43,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.RequestDispatcher;
import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -43,7 +55,7 @@
*/
public class PagePortletControllerContext extends AbstractPortletControllerContext
{
-
+
/** . */
private final Page page;
@@ -57,18 +69,97 @@
HttpServletRequest req,
HttpServletResponse resp,
ServletContext servletContext,
- Page page,
PortletInvoker invoker)
- throws IllegalRequestException, IOException, ClassNotFoundException
+ throws IllegalRequestException, IOException, ClassNotFoundException, ServletException
{
super(req, resp, servletContext);
+
//
- this.page = page;
+ PageNavigationalState pageState = null;
+ if (getRequest() instanceof PortletRequest)
+ {
+ PortletRequest request = (PortletRequest)getRequest();
+ pageState = request.getPageState();
+ }
+ else if (getRequest() instanceof PageScopedFullPortletResourceRequest)
+ {
+ PageScopedFullPortletResourceRequest request = (PageScopedFullPortletResourceRequest)getRequest();
+ pageState = request.getPageState();
+ }
+
+ //
+ String pageId = null;
+ if (pageState != null)
+ {
+ String[] values = pageState.getPublicNavigationalState(Page.PAGE_ID_NAME);
+ if (values != null && values.length > 0)
+ {
+ pageId = values[0];
+ }
+ }
+ if (pageId == null)
+ {
+ pageId = "/index.jsp";
+ }
+
+ //
+ RequestDispatcher dispatcher = req.getRequestDispatcher(pageId);
+
+ //
+ BufferingResponse bufferingResponse = new BufferingResponse(resp);
+
+ //
+ dispatcher.include(req, bufferingResponse);
+
+ //
+ ResponseBuffer buffer = bufferingResponse.getBuffer();
+ buffer.close();
+
+ // Collect portlets to create the page
+ int counter = 0;
+ Map<String, Window> windows = new HashMap<String, Window>();
+ for (Chunk chunk : buffer.getChunks())
+ {
+ if (chunk instanceof PortletChunk)
+ {
+ PortletChunk portletChunk = (PortletChunk)chunk;
+ String windowId = "" + counter++;
+
+ //
+ try
+ {
+ for (Portlet portlet : invoker.getPortlets())
+ {
+ PortletInfo portletInfo = portlet.getInfo();
+ String portletName = portletInfo.getName();
+ String applicationName = portletInfo.getApplicationName();
+
+ //
+ if (applicationName.equals(portletChunk.getApplicationName()) && portletName.equals(portletChunk.getPortletName()))
+ {
+ windows.put(windowId, new Window(windowId, portlet));
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new ServletException(e);
+ }
+ }
+ }
+
+ //
+ this.page = new Page(buffer.getChunks(), windows, pageId);
this.invoker = invoker;
this.eventControllerContext = new EventControllerContextImpl(invoker);
}
+ public Page getPage()
+ {
+ return page;
+ }
+
protected Portlet getPortlet(String windowId) throws PortletInvokerException
{
Window window = page.getWindow(windowId);
16 years, 4 months
JBoss Portal SVN: r9812 - modules/portlet/trunk/test/src/test/resources/simple-portal-war.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 17:15:06 -0500 (Wed, 06 Feb 2008)
New Revision: 9812
Modified:
modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
Log:
portlet taglib not used here
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-06 22:12:01 UTC (rev 9811)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-06 22:15:06 UTC (rev 9812)
@@ -1,6 +1,5 @@
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/portal.tld" prefix="portal" %>
-<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ page isELIgnored="false" %>
<html>
<body>
16 years, 4 months
JBoss Portal SVN: r9811 - in modules/portlet/trunk: test/src/main/java/org/jboss/portal/portlet/test and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2008-02-06 17:12:01 -0500 (Wed, 06 Feb 2008)
New Revision: 9811
Added:
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/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/Window.java
Removed:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/taglib/
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java
modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
Log:
more implementation of the taglib
Modified: modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java
===================================================================
--- modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-02-06 21:56:20 UTC (rev 9810)
+++ modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/impl/info/ContainerPortletInfo.java 2008-02-06 22:12:01 UTC (rev 9811)
@@ -163,7 +163,7 @@
public String getApplicationName()
{
- return null;
+ return applicationName;
}
public Map<String, ContainerOptionInfo> getOptions()
Added: 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 (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/AbstractPortletControllerContext.java 2008-02-06 22:12:01 UTC (rev 9811)
@@ -0,0 +1,357 @@
+/******************************************************************************
+ * 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.controller;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.io.IOTools;
+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.portlet.ContainerURL;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.cache.CacheLevel;
+import org.jboss.portal.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
+import org.jboss.portal.portlet.controller.request.ControllerRequest;
+import org.jboss.portal.portlet.controller.request.FullScopedCacheablePortletResourceRequest;
+import org.jboss.portal.portlet.controller.request.PageScopedFullPortletResourceRequest;
+import org.jboss.portal.portlet.controller.request.PortletActionRequest;
+import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
+import org.jboss.portal.portlet.controller.request.PortletScopedPortletResourceRequest;
+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.impl.spi.AbstractClientContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext;
+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.info.PortletInfo;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.EventInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ResourceInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.test.StringCodec;
+import static org.jboss.portal.portlet.test.URLParameterConstants.*;
+import org.jboss.portal.web.Body;
+import org.jboss.portal.web.IllegalRequestException;
+import org.jboss.portal.web.WebRequest;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractPortletControllerContext implements PortletControllerContext
+{
+
+ /** . */
+ public static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
+
+ /** . */
+ public static final int NAV_SCOPE = 0;
+
+ /** . */
+ public static final int SESSION_SCOPE = 1;
+
+ /** . */
+ private final HttpServletRequest req;
+
+ /** . */
+ private final HttpServletResponse resp;
+
+ /** . */
+ private final ServletContext servletContext;
+
+ /** . */
+ private final ControllerRequest request;
+
+ /** . */
+ private final StateControllerContextImpl stateControllerContext;
+
+ public AbstractPortletControllerContext(
+ HttpServletRequest req,
+ HttpServletResponse resp,
+ ServletContext servletContext)
+ throws IllegalRequestException, IOException, ClassNotFoundException
+ {
+ StateControllerContextImpl tmp = new StateControllerContextImpl(this);
+
+ // The nav state provided with the request
+ PageNavigationalState pageState = null;
+
+ // The request decoded if not null
+ ControllerRequest request = null;
+
+ // Process
+ String pathInfo = req.getPathInfo();
+ if (pathInfo != null && pathInfo.startsWith("/") && pathInfo.length() > 1)
+ {
+ // Get the target portlet
+ String targetId = StringCodec.decode(pathInfo.substring(1));
+
+ // 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 = Tools.fromHexString(context);
+ pageState = tmp.unserialize(bytes);
+ }
+
+ //
+ Mode mode = null;
+ if (req.getParameter(MODE) != null)
+ {
+ mode = Mode.create(req.getParameter(MODE));
+ }
+
+ //
+ WindowState windowState = null;
+ if (req.getParameter(WINDOW_STATE) != null)
+ {
+ windowState = WindowState.create(req.getParameter(WINDOW_STATE));
+ }
+
+ //
+ String navigationalStateString = req.getParameter(NAVIGATIONAL_STATE);
+ StateString navigationalState = null;
+ if (navigationalStateString != null)
+ {
+ navigationalState = ParametersStateString.create(navigationalStateString);
+ }
+
+ //
+ WindowNavigationalState windowNavigationalState = new WindowNavigationalState(navigationalState, mode, windowState);
+
+ //
+ String type = req.getParameter(LIFECYCLE_TYPE);
+ if (RESOURCE_LIFECYCLE.equals(type))
+ {
+ StateString resourceState = ParametersStateString.create(req.getParameter(RESOURCE_STATE));
+ String resourceId = req.getParameter(RESOURCE_ID);
+
+ //
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
+
+ //
+ CacheLevel resourceCacheLevel = CacheLevel.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
+
+ //
+ switch (resourceCacheLevel)
+ {
+ case FULL:
+ request = new FullScopedCacheablePortletResourceRequest(
+ this,
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters);
+ break;
+ case PORTLET:
+ request = new PortletScopedPortletResourceRequest(
+ this,
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters,
+ windowNavigationalState);
+ break;
+ case PAGE:
+ request = new PageScopedFullPortletResourceRequest(
+ this,
+ targetId,
+ resourceId,
+ resourceState,
+ formParameters,
+ pageState,
+ windowNavigationalState);
+ break;
+ }
+ }
+ else
+ {
+ if (ACTION_LIFECYCLE.equals(type))
+ {
+ ParameterMap formParameters = null;
+ if (ri.getBody() instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)ri.getBody()).getParameters();
+ }
+
+ //
+ StateString interactionState = ParametersStateString.create(req.getParameter(INTERACTION_STATE));
+
+ //
+ request = new PortletActionRequest(
+ this,
+ targetId,
+ interactionState,
+ formParameters,
+ windowNavigationalState,
+ pageState);
+ }
+ else
+ {
+ Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES)));
+
+ //
+ request = new PortletRenderRequest(
+ this,
+ targetId,
+ windowNavigationalState,
+ publicNavigationalStateChanges,
+ pageState);
+ }
+ }
+ }
+
+ //
+ this.request = request;
+ this.req = req;
+ this.resp = resp;
+ this.servletContext = servletContext;
+ this.stateControllerContext = tmp;
+ }
+
+ public ControllerRequest getRequest()
+ {
+ return request;
+ }
+
+ public ServletContext getServletContext()
+ {
+ return servletContext;
+ }
+
+ public HttpServletRequest getClientRequest()
+ {
+ return req;
+ }
+
+ public HttpServletResponse getClientResponse()
+ {
+ return resp;
+ }
+
+ public PortletInfo getPortletInfo(String windowId) throws PortletInvokerException
+ {
+ return getPortlet(windowId).getInfo();
+ }
+
+ protected abstract Portlet getPortlet(String windowId) throws PortletInvokerException;
+
+ protected abstract PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException;
+
+ public abstract EventControllerContext getEventControllerContext();
+
+ public StateControllerContext getStateControllerContext()
+ {
+ return stateControllerContext;
+ }
+
+ public PortletInvocationResponse invoke(String windowId, ActionInvocation actionInvocation) throws PortletInvokerException
+ {
+
+ Portlet portlet = getPortlet(windowId);
+
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+
+ actionInvocation.setClientContext(new AbstractClientContext(req));
+ actionInvocation.setServerContext(new AbstractServerContext(req, resp));
+ actionInvocation.setInstanceContext(instanceContext);
+ actionInvocation.setUserContext(new AbstractUserContext(req));
+ actionInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ actionInvocation.setPortalContext(new TestPortalContext());
+ actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ actionInvocation.setRequestContext(new AbstractRequestContext(req));
+ actionInvocation.setTarget(instanceContext.getTarget());
+
+ return invoke(actionInvocation);
+ }
+
+ public PortletInvocationResponse invoke(String windowId, List<Cookie> requestCookies, EventInvocation eventInvocation) throws PortletInvokerException
+ {
+ Portlet portlet = getPortlet(windowId);
+
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+
+ eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies));
+ eventInvocation.setServerContext(new AbstractServerContext(req, resp));
+ eventInvocation.setInstanceContext(instanceContext);
+ eventInvocation.setUserContext(new AbstractUserContext(req));
+ eventInvocation.setWindowContext(new AbstractWindowContext(windowId));
+ eventInvocation.setPortalContext(new TestPortalContext());
+ eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ eventInvocation.setTarget(instanceContext.getTarget());
+
+ return invoke(eventInvocation);
+ }
+
+ public PortletInvocationResponse invoke(String windowId, ResourceInvocation resourceInvocation) throws PortletInvokerException
+ {
+ Portlet portlet = getPortlet(windowId);
+
+ TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
+
+ resourceInvocation.setClientContext(new AbstractClientContext(req));
+ resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
+ resourceInvocation.setInstanceContext(instanceContext);
+ resourceInvocation.setUserContext(new AbstractUserContext(req));
+ resourceInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
+ resourceInvocation.setPortalContext(new TestPortalContext());
+ resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
+ resourceInvocation.setRequestContext(new AbstractRequestContext(req));
+ resourceInvocation.setTarget(instanceContext.getTarget());
+
+ return invoke(resourceInvocation);
+ }
+
+ public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageState)
+ {
+ 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/PortletControllerContextImpl.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-06 21:56:20 UTC (rev 9810)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletControllerContextImpl.java 2008-02-06 22:12:01 UTC (rev 9811)
@@ -83,312 +83,43 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PortletControllerContextImpl implements PortletControllerContext
+public class PortletControllerContextImpl extends AbstractPortletControllerContext
{
/** . */
- public static final MarkupInfo MARKUP_INFO = new MarkupInfo(MediaType.HTML, "UTF8");
-
- /** . */
- public static final int NAV_SCOPE = 0;
-
- /** . */
- public static final int SESSION_SCOPE = 1;
-
- /** . */
- private final HttpServletRequest req;
-
- /** . */
- private final HttpServletResponse resp;
-
- /** . */
- private final ServletContext servletContext;
-
- /** . */
- private final ControllerRequest request;
-
- /** . */
private final PortletInvoker invoker;
-
+
/** . */
private final EventControllerContext eventControllerContext;
- /** . */
- private final StateControllerContextImpl stateControllerContext;
-
- public PortletControllerContextImpl(
- HttpServletRequest req,
- HttpServletResponse resp,
- ServletContext servletContext)
+ public PortletControllerContextImpl(HttpServletRequest req, HttpServletResponse resp, ServletContext servletContext)
throws IllegalRequestException, IOException, ClassNotFoundException
{
- PortletInvoker invoker = (PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
+ super(req, resp, servletContext);
//
- StateControllerContextImpl tmp = new StateControllerContextImpl(this);
-
- // The nav state provided with the request
- PageNavigationalState pageState = null;
-
- // The request decoded if not null
- ControllerRequest request = null;
-
- // Process
- String pathInfo = req.getPathInfo();
- if (pathInfo != null && pathInfo.startsWith("/") && pathInfo.length() > 1)
- {
- // Get the target portlet
- String targetId = StringCodec.decode(pathInfo.substring(1));
-
- // 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 = Tools.fromHexString(context);
- pageState = tmp.unserialize(bytes);
- }
-
- //
- Mode mode = null;
- if (req.getParameter(MODE) != null)
- {
- mode = Mode.create(req.getParameter(MODE));
- }
-
- //
- WindowState windowState = null;
- if (req.getParameter(WINDOW_STATE) != null)
- {
- windowState = WindowState.create(req.getParameter(WINDOW_STATE));
- }
-
- //
- String navigationalStateString = req.getParameter(NAVIGATIONAL_STATE);
- StateString navigationalState = null;
- if (navigationalStateString != null)
- {
- navigationalState = ParametersStateString.create(navigationalStateString);
- }
-
- //
- WindowNavigationalState windowNavigationalState = new WindowNavigationalState(navigationalState, mode, windowState);
-
- //
- String type = req.getParameter(LIFECYCLE_TYPE);
- if (RESOURCE_LIFECYCLE.equals(type))
- {
- StateString resourceState = ParametersStateString.create(req.getParameter(RESOURCE_STATE));
- String resourceId = req.getParameter(RESOURCE_ID);
-
- //
- ParameterMap formParameters = null;
- if (ri.getBody() instanceof Body.Form)
- {
- formParameters = ((Body.Form)ri.getBody()).getParameters();
- }
-
- //
- CacheLevel resourceCacheLevel = CacheLevel.valueOf(req.getParameter(RESOURCE_CACHEABILITY));
-
- //
- switch (resourceCacheLevel)
- {
- case FULL:
- request = new FullScopedCacheablePortletResourceRequest(
- this,
- targetId,
- resourceId,
- resourceState,
- formParameters);
- break;
- case PORTLET:
- request = new PortletScopedPortletResourceRequest(
- this,
- targetId,
- resourceId,
- resourceState,
- formParameters,
- windowNavigationalState);
- break;
- case PAGE:
- request = new PageScopedFullPortletResourceRequest(
- this,
- targetId,
- resourceId,
- resourceState,
- formParameters,
- pageState,
- windowNavigationalState);
- break;
- }
- }
- else
- {
- if (ACTION_LIFECYCLE.equals(type))
- {
- ParameterMap formParameters = null;
- if (ri.getBody() instanceof Body.Form)
- {
- formParameters = ((Body.Form)ri.getBody()).getParameters();
- }
-
- //
- StateString interactionState = ParametersStateString.create(req.getParameter(INTERACTION_STATE));
-
- //
- request = new PortletActionRequest(
- this,
- targetId,
- interactionState,
- formParameters,
- windowNavigationalState,
- pageState);
- }
- else
- {
- Map<String, String[]> publicNavigationalStateChanges = (Map<String, String[]>)IOTools.unserialize(Tools.fromHexString(req.getParameter(PUBLIC_NAVIGATIONAL_STATE_CHANGES)));
-
- //
- request = new PortletRenderRequest(
- this,
- targetId,
- windowNavigationalState,
- publicNavigationalStateChanges,
- pageState);
- }
- }
- }
-
- //
- this.request = request;
- this.req = req;
- this.resp = resp;
- this.servletContext = servletContext;
- this.invoker = invoker;
+ this.invoker = (PortletInvoker)servletContext.getAttribute("ConsumerPortletInvoker");
this.eventControllerContext = new EventControllerContextImpl(invoker);
- this.stateControllerContext = tmp;
}
- public ControllerRequest getRequest()
+ protected Portlet getPortlet(String windowId) throws PortletInvokerException
{
- return request;
- }
-
- public ServletContext getServletContext()
- {
- return servletContext;
- }
-
- public HttpServletRequest getClientRequest()
- {
- return req;
- }
-
- public HttpServletResponse getClientResponse()
- {
- return resp;
- }
-
- public PortletInfo getPortletInfo(String windowId) throws PortletInvokerException
- {
- return _getPortlet(windowId).getInfo();
- }
-
- private Portlet _getPortlet(String windowId) throws PortletInvokerException
- {
return invoker.getPortlet(PortletContext.createPortletContext(windowId));
}
- public PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
+ protected PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
{
return invoker.invoke(invocation);
}
- public Collection<Portlet> getPortlets() throws PortletInvokerException
- {
- return invoker.getPortlets();
- }
-
public EventControllerContext getEventControllerContext()
{
return eventControllerContext;
}
- public StateControllerContext getStateControllerContext()
+ public Collection<Portlet> getPortlets() throws PortletInvokerException
{
- return stateControllerContext;
+ return invoker.getPortlets();
}
- public String renderURL(String windowId, PageNavigationalState pageState, ContainerURL containerURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
- {
- PortletURLRenderer renderer = new PortletURLRenderer(stateControllerContext, pageState, windowId, req, resp);
-
- //
- return renderer.renderURL(containerURL, wantSecure, wantAuthenticated, relative);
- }
-
- public PortletInvocationResponse invoke(String windowId, ActionInvocation actionInvocation) throws PortletInvokerException
- {
-
- Portlet portlet = _getPortlet(windowId);
-
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
-
- actionInvocation.setClientContext(new AbstractClientContext(req));
- actionInvocation.setServerContext(new AbstractServerContext(req, resp));
- actionInvocation.setInstanceContext(instanceContext);
- actionInvocation.setUserContext(new AbstractUserContext(req));
- actionInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- actionInvocation.setPortalContext(new TestPortalContext());
- actionInvocation.setSecurityContext(new AbstractSecurityContext(req));
- actionInvocation.setRequestContext(new AbstractRequestContext(req));
- actionInvocation.setTarget(instanceContext.getTarget());
-
- return invoke(actionInvocation);
- }
-
- public PortletInvocationResponse invoke(String windowId, List<Cookie> requestCookies, EventInvocation eventInvocation) throws PortletInvokerException
- {
- Portlet portlet = _getPortlet(windowId);
-
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
-
- eventInvocation.setClientContext(new AbstractClientContext(req, requestCookies));
- eventInvocation.setServerContext(new AbstractServerContext(req, resp));
- eventInvocation.setInstanceContext(instanceContext);
- eventInvocation.setUserContext(new AbstractUserContext(req));
- eventInvocation.setWindowContext(new AbstractWindowContext(windowId));
- eventInvocation.setPortalContext(new TestPortalContext());
- eventInvocation.setSecurityContext(new AbstractSecurityContext(req));
- eventInvocation.setTarget(instanceContext.getTarget());
-
- return invoke(eventInvocation);
- }
-
- public PortletInvocationResponse invoke(String windowId, ResourceInvocation resourceInvocation) throws PortletInvokerException
- {
- Portlet portlet = _getPortlet(windowId);
-
- TestInstanceContext instanceContext = new TestInstanceContext(req, portlet.getContext(), true);
-
- resourceInvocation.setClientContext(new AbstractClientContext(req));
- resourceInvocation.setServerContext(new AbstractServerContext(req, resp));
- resourceInvocation.setInstanceContext(instanceContext);
- resourceInvocation.setUserContext(new AbstractUserContext(req));
- resourceInvocation.setWindowContext(new AbstractWindowContext(portlet.getContext().getId()));
- resourceInvocation.setPortalContext(new TestPortalContext());
- resourceInvocation.setSecurityContext(new AbstractSecurityContext(req));
- resourceInvocation.setRequestContext(new AbstractRequestContext(req));
- resourceInvocation.setTarget(instanceContext.getTarget());
-
- return invoke(resourceInvocation);
- }
-
- public PortletInvocationContext createPortletInvocationContext(String windowId, PageNavigationalState pageState)
- {
- return new TestPortletInvocationContext(stateControllerContext, req, resp, windowId, pageState, MARKUP_INFO);
- }
}
Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-06 21:56:20 UTC (rev 9810)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerServlet.java 2008-02-06 22:12:01 UTC (rev 9811)
@@ -28,6 +28,16 @@
import org.jboss.portal.portlet.test.jsp.response.CharsChunk;
import org.jboss.portal.portlet.test.jsp.response.PortletChunk;
import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+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.response.ControllerResponse;
+import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.info.PortletInfo;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -36,6 +46,7 @@
import javax.servlet.RequestDispatcher;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -44,9 +55,23 @@
public class ControllerServlet extends HttpServlet
{
-
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
+ try
+ {
+ _service(req, resp);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ServletException(e);
+ }
+ }
+
+ protected void _service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, ClassNotFoundException
+ {
+ PortletInvoker invoker = (PortletInvoker)getServletContext().getAttribute("ConsumerPortletInvoker");
+
+ //
RequestDispatcher dispatcher = req.getRequestDispatcher("/index.jsp");
//
@@ -59,9 +84,75 @@
ResponseBuffer buffer = bufferingResponse.getBuffer();
buffer.close();
+ // Collect portlets to create the page
+ int counter = 0;
+ Page page = new Page();
+ for (Chunk chunk : buffer.getChunks())
+ {
+ if (chunk instanceof PortletChunk)
+ {
+ PortletChunk portletChunk = (PortletChunk)chunk;
+ String windowId = "" + counter++;
+
+ //
+ try
+ {
+ for (Portlet portlet : invoker.getPortlets())
+ {
+ PortletInfo portletInfo = portlet.getInfo();
+ String portletName = portletInfo.getName();
+ String applicationName = portletInfo.getApplicationName();
+
+ //
+ if (applicationName.equals(portletChunk.getApplicationName()) && portletName.equals(portletChunk.getPortletName()))
+ {
+ page.addWindow(new Window(windowId, portlet));
+ }
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new ServletException(e);
+ }
+ }
+ }
+
//
+ PagePortletControllerContext context = new PagePortletControllerContext(req, resp, getServletContext(), page, invoker);
+
+ //
+ PageNavigationalState pageState = null;
+ if (context.getRequest() != null)
+ {
+ ControllerResponse controllerResponse;
+ try
+ {
+ controllerResponse = new PortletController().process(context.getRequest());
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new ServletException(e);
+ }
+
+ //
+ if (controllerResponse instanceof PageUpdateResponse)
+ {
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)controllerResponse;
+ pageState = pageUpdate.getPageState();
+ }
+ }
+ else
+ {
+ pageState = context.getStateControllerContext().createPageState();
+ }
+
+ //
+ Map<String, PortletInvocationResponse> responses = page.render(context, pageState);
+
+ //
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
+ int count = 0;
for (Chunk chunk : buffer.getChunks())
{
if (chunk instanceof BytesChunk)
@@ -77,7 +168,39 @@
else if (chunk instanceof PortletChunk)
{
PortletChunk portletChunk = (PortletChunk)chunk;
- writer.write("Portlet[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
+ String windowId = "" + count++;
+
+ PortletInvocationResponse response = responses.get(windowId);
+ if (response != null)
+ {
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ 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);
+ }
+ }
+ else
+ {
+ writer.write(response.getClass().getSimpleName() + "[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
+ }
+ }
+ else
+ {
+ writer.write("Empty[" + portletChunk.getPortletName() + "," + portletChunk.getApplicationName() + "]");
+ }
}
}
Added: 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 (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-06 22:12:01 UTC (rev 9811)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * 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.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class Page
+{
+
+ /** . */
+ private Map<String, Window> windows;
+
+ public Page()
+ {
+ this.windows = new HashMap<String, Window>();
+ }
+
+ public void addWindow(Window window)
+ {
+ windows.put(window.getId(), window);
+ }
+
+ public Window getWindow(String windowId)
+ {
+ return windows.get(windowId);
+ }
+
+ public Map<String, PortletInvocationResponse> render(PortletControllerContext context, PageNavigationalState pageState)
+ {
+ Map<String, PortletInvocationResponse> responses = new HashMap<String, PortletInvocationResponse>();
+
+ //
+ for (Window window : windows.values())
+ {
+ PortletInvocationResponse response = window.render(context, pageState);
+
+ //
+ if (response != null)
+ {
+ responses.put(window.getId(), response);
+ }
+ }
+
+ //
+ return responses;
+ }
+}
Added: 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 (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/PagePortletControllerContext.java 2008-02-06 22:12:01 UTC (rev 9811)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * 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.AbstractPortletControllerContext;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.controller.event.EventControllerContext;
+import org.jboss.portal.portlet.controller.impl.event.EventControllerContextImpl;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.web.IllegalRequestException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PagePortletControllerContext extends AbstractPortletControllerContext
+{
+
+ /** . */
+ private final Page page;
+
+ /** . */
+ private final PortletInvoker invoker;
+
+ /** . */
+ private final EventControllerContext eventControllerContext;
+
+ public PagePortletControllerContext(
+ HttpServletRequest req,
+ HttpServletResponse resp,
+ ServletContext servletContext,
+ Page page,
+ PortletInvoker invoker)
+ throws IllegalRequestException, IOException, ClassNotFoundException
+ {
+ super(req, resp, servletContext);
+
+ //
+ this.page = page;
+ this.invoker = invoker;
+ this.eventControllerContext = new EventControllerContextImpl(invoker);
+ }
+
+ protected Portlet getPortlet(String windowId) throws PortletInvokerException
+ {
+ Window window = page.getWindow(windowId);
+ return window.getPortlet();
+ }
+
+ protected PortletInvocationResponse invoke(PortletInvocation invocation) throws PortletInvokerException
+ {
+ return invoker.invoke(invocation);
+ }
+
+ public EventControllerContext getEventControllerContext()
+ {
+ return eventControllerContext;
+ }
+}
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Window.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Window.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Window.java 2008-02-06 22:12:01 UTC (rev 9811)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * 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.StateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.test.controller.TestInstanceContext;
+import org.jboss.portal.portlet.test.controller.TestPortalContext;
+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.portlet.controller.PortletControllerContext;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
+import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class Window
+{
+
+ /** . */
+ private final String id;
+
+ /** . */
+ private final Portlet portlet;
+
+ public Window(String id, Portlet portlet)
+ {
+ this.id = id;
+ this.portlet = portlet;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Portlet getPortlet()
+ {
+ return portlet;
+ }
+
+ public PortletInvocationResponse render(
+ PortletControllerContext context,
+ PageNavigationalState pageState)
+ {
+ WindowNavigationalState windowNS = pageState.getWindowNavigationalState(id);
+
+ //
+ 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();
+ }
+ }
+
+ //
+ ParameterMap publicNS = pageState.getPublicNavigationalState(id);
+
+ //
+ PortletInvocationContext renderContext = context.createPortletInvocationContext(id, pageState);
+ RenderInvocation render = new RenderInvocation(renderContext);
+ render.setClientContext(new AbstractClientContext(context.getClientRequest()));
+ render.setServerContext(new AbstractServerContext(context.getClientRequest(), context.getClientResponse()));
+ render.setInstanceContext(new TestInstanceContext(context.getClientRequest(), portlet.getContext(), false));
+ render.setUserContext(new AbstractUserContext(context.getClientRequest()));
+ render.setWindowContext(new AbstractWindowContext(id));
+ render.setPortalContext(new TestPortalContext());
+ render.setSecurityContext(new AbstractSecurityContext(context.getClientRequest()));
+ render.setTarget(portlet.getContext());
+ render.setMode(mode);
+ render.setWindowState(windowState);
+ render.setNavigationalState(portletNS);
+ render.setPublicNavigationalState(publicNS);
+
+ //
+ try
+ {
+ return ((PagePortletControllerContext)context).invoke(render);
+
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+
+ // todo
+
+ //
+ return null;
+ }
+ }
+}
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-06 21:56:20 UTC (rev 9810)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-06 22:12:01 UTC (rev 9811)
@@ -5,11 +5,15 @@
<html>
<body>
<portal:page>
- BEFORE
+ ONE
<portal:portlet
+ name="GoogleWeather"
+ applicationName="google-weather-portlet"/>
+ TWO
+ <portal:portlet
name="GoogleMap"
applicationName="google-map-portlet"/>
- AFTER
+ THREE
</portal:page>
</body>
</html>
16 years, 4 months
JBoss Portal SVN: r9810 - in modules/portlet/trunk/test/src: test and 3 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-02-06 16:56:20 -0500 (Wed, 06 Feb 2008)
New Revision: 9810
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/samples/RemoteControlResourcePortlet.java
modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/
modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/
modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/web.xml
Modified:
modules/portlet/trunk/test/src/test/build.xml
Log:
- Resource serving portlet supposed to act as a remote control... doesn't really work right now.
Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/samples/RemoteControlResourcePortlet.java
===================================================================
--- modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/samples/RemoteControlResourcePortlet.java (rev 0)
+++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/samples/RemoteControlResourcePortlet.java 2008-02-06 21:56:20 UTC (rev 9810)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2008, Your Corporation. All Rights Reserved.
+ */
+
+package org.jboss.portal.simple.samples;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceURL;
+import javax.portlet.WindowState;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class RemoteControlResourcePortlet extends GenericPortlet
+{
+ private static final String ZIPCODE = "zipcode";
+
+ @Override
+ protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException
+ {
+ renderResponse.setContentType("text/html");
+ PrintWriter printWriter = renderResponse.getWriter();
+ printWriter.print("<p><a href=\"");
+ String url = "javascript:window.open('";
+ ResourceURL resource = renderResponse.createResourceURL();
+ url += resource + "','Remote Control','width=400,height=200')";
+ printWriter.print(url);
+ printWriter.print("\">Open remote control!</a></p>");
+ }
+
+ @Override
+ public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException, IOException
+ {
+ resourceResponse.setContentType("text/html");
+ PrintWriter writer = resourceResponse.getWriter();
+ PortletURL url = resourceResponse.createRenderURL();
+ url.setWindowState(WindowState.MINIMIZED);
+ writer.print("<ul><li><a target='_parent' href='" + url + "'>minimize</a></li>");
+ url.setWindowState(WindowState.MAXIMIZED);
+ writer.print("<li><a href='" + url + "'>maximize</a></li>");
+ url.setWindowState(WindowState.NORMAL);
+ writer.print("<li><a href='" + url + "'>normal</a></li></ul>");
+ writer.print("<p><b>'zipcode'</b> public render parameter value: " + resourceRequest.getParameter(ZIPCODE) + "<br/>");
+ writer.print("<p>Set value of <b>'zipcode'</b> public render parameter to:");
+ url.setParameter(ZIPCODE, "80201");
+ writer.print("<li><a href='" + url + "'>Denver</a>");
+ url.setParameter(ZIPCODE, "94102");
+ writer.print("<li><a href='" + url + "'>San Francisco</a>");
+ url.setParameter(ZIPCODE, "20001");
+ writer.print("<li><a href='" + url + "'>Washington, DC</a>");
+ writer.print("</ul></p>");
+ }
+}
Property changes on: modules/portlet/trunk/test/src/main/java/org/jboss/portal/simple/samples/RemoteControlResourcePortlet.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-06 20:39:58 UTC (rev 9809)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-06 21:56:20 UTC (rev 9810)
@@ -759,6 +759,15 @@
<jar jarfile="${target}/google-weather-portlet.war">
<fileset dir="${test.temp.dir}/google-weather-portlet-war"/>
</jar>
+
+ <copy todir="${test.temp.dir}/remotecontrol-portlet-war">
+ <fileset dir="src/test/resources/remotecontrol-portlet-war"/>
+ <fileset dir="${target}/classes"
+ includes="org/jboss/portal/simple/samples/RemoteControlResourcePortlet.class"/>
+ </copy>
+ <jar jarfile="${target}/remotecontrol-portlet.war">
+ <fileset dir="${test.temp.dir}/remotecontrol-portlet-war"/>
+ </jar>
</target>
</project>
\ No newline at end of file
Copied: modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/portlet.xml (from rev 9803, modules/portlet/trunk/test/src/test/resources/google-map-portlet-war/WEB-INF/portlet.xml)
===================================================================
--- modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/portlet.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/portlet.xml 2008-02-06 21:56:20 UTC (rev 9810)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+ version="2.0">
+ <portlet>
+ <description>Portlet controlling display of other portlets</description>
+ <portlet-name>RemoteControl</portlet-name>
+ <display-name>Remote Control Resource Portlet</display-name>
+ <portlet-class>org.jboss.portal.simple.samples.RemoteControlResourcePortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Remote Control Resource Portlet</title>
+ <keywords>sample,resource,remotecontrol</keywords>
+ </portlet-info>
+ <supported-public-render-parameter>zipcode</supported-public-render-parameter>
+ </portlet>
+
+ <public-render-parameter>
+ <identifier>zipcode</identifier>
+ <qname xmlns:g='urn:jboss:portal:simple:google'>g:zipcode</qname>
+ </public-render-parameter>
+</portlet-app>
+
Copied: modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/web.xml (from rev 9803, modules/portlet/trunk/test/src/test/resources/google-map-portlet-war/WEB-INF/web.xml)
===================================================================
--- modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/web.xml (rev 0)
+++ modules/portlet/trunk/test/src/test/resources/remotecontrol-portlet-war/WEB-INF/web.xml 2008-02-06 21:56:20 UTC (rev 9810)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app/>
+
16 years, 4 months