Author: julien(a)jboss.com
Date: 2008-06-01 19:08:16 -0400 (Sun, 01 Jun 2008)
New Revision: 10891
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandlerRegistry.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java
Modified:
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/jboss-beans.xml
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java
Log:
needed to add a notion of content handler/registry for window content similar to 2.7
Modified:
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/jboss-beans.xml
===================================================================
---
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/jboss-beans.xml 2008-06-01
15:32:27 UTC (rev 10890)
+++
modules/presentation/trunk/portal/src/main/artifacts/presentation-portal-war/WEB-INF/jboss-beans.xml 2008-06-01
23:08:16 UTC (rev 10891)
@@ -131,7 +131,6 @@
</constructor>
</bean>
-
<bean name="StructuralStateContext"
class="org.jboss.portal.presentation.portal.model.StructuralStateContextImpl"/>
<bean name="StructuralStateContextImporter"
class="org.jboss.portal.presentation.portal.servlet.StructuralStateContextImporter">
@@ -142,10 +141,25 @@
<bean name="PresentationServer"
class="org.jboss.portal.presentation.portal.PresentationServerImpl">
<constructor>
<parameter><inject
bean="StructuralStateContext"/></parameter>
- <parameter><inject
bean="ConsumerPortletInvoker"/></parameter>
+ <parameter><inject
bean="ContentHandlerRegistry"/></parameter>
</constructor>
</bean>
+ <bean name="ContentHandlerRegistry"
class="org.jboss.portal.presentation.portal.content.ContentHandlerRegistry"/>
+ <bean name="PortletContentHandler"
class="org.jboss.portal.presentation.portal.content.portlet.PortletContentHandler">
+ <property name="portletInvoker"><inject
bean="ConsumerPortletInvoker"/></property>
+ <install bean="ContentHandlerRegistry"
method="addContentHandler">
+ <parameter>portlet</parameter>
+ <parameter><this/></parameter>
+ </install>
+ </bean>
+ <bean name="MarkupContentHandler"
class="org.jboss.portal.presentation.portal.content.markup.MarkupContentHandler">
+ <install bean="ContentHandlerRegistry"
method="addContentHandler">
+ <parameter>markup</parameter>
+ <parameter><this/></parameter>
+ </install>
+ </bean>
+
</deployment>
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-06-01
15:32:27 UTC (rev 10890)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -28,9 +28,8 @@
import org.jboss.portal.presentation.portal.model.WindowNode;
import org.jboss.portal.presentation.portal.model.PageNode;
import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
-import
org.jboss.portal.presentation.portal.content.portlet.protocol.PortletContainerAction;
-import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletControllerContext;
-import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletPageNavigationalState;
+import org.jboss.portal.presentation.portal.content.ContentHandlerRegistry;
+import org.jboss.portal.presentation.portal.content.ContentHandler;
import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.protocol.ErrorResponse;
import org.jboss.portal.presentation.protocol.ProtocolAction;
@@ -38,22 +37,13 @@
import org.jboss.portal.presentation.protocol.UIObjectAction;
import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
import org.jboss.portal.presentation.protocol.LinkActivation;
+import org.jboss.portal.presentation.protocol.ProtocolResponse;
import org.jboss.portal.presentation.server.PresentationRequest;
import org.jboss.portal.presentation.server.PresentationResponse;
import org.jboss.portal.presentation.server.PresentationServer;
import org.jboss.portal.presentation.server.PresentationServerException;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
import org.jboss.portal.common.NotYetImplemented;
-import org.jboss.portal.portlet.PortletInvoker;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
-import org.jboss.portal.portlet.controller.request.ControllerRequest;
-import org.jboss.portal.portlet.controller.request.PortletActionRequest;
-import org.jboss.portal.portlet.controller.state.PortletWindowNavigationalState;
-import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
-import org.jboss.portal.portlet.controller.response.ControllerResponse;
-import org.jboss.portal.portlet.controller.PortletController;
/**
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -66,12 +56,12 @@
private StructuralStateContextImpl structuralStateContext;
/** . */
- private PortletInvoker portletInvoker;
+ private ContentHandlerRegistry contentHandlerRegistry;
- public PresentationServerImpl(StructuralStateContextImpl structuralStateContext,
PortletInvoker portletInvoker)
+ public PresentationServerImpl(StructuralStateContextImpl structuralStateContext,
ContentHandlerRegistry contentHandlerRegistry)
{
this.structuralStateContext = structuralStateContext;
- this.portletInvoker = portletInvoker;
+ this.contentHandlerRegistry = contentHandlerRegistry;
}
public StructuralStateContext getStructuralStateContext()
@@ -81,13 +71,15 @@
public WindowContent renderWindow(PresentationClient client, String windowId) throws
PresentationServerException
{
- WindowNode windowNode = (WindowNode)structuralStateContext.getNode(windowId);
+ WindowNode window = (WindowNode)structuralStateContext.getNode(windowId);
- WindowNode.Content content = windowNode.getContent();
+ WindowNode.Content content = window.getContent();
- WindowContent windowContent = content.render(windowNode, client, portletInvoker);
-
- return windowContent;
+ String contentType = content.getType();
+
+ ContentHandler handler = contentHandlerRegistry.getContentHandler(contentType);
+
+ return handler.render(window, client);
}
public PresentationResponse process(PresentationClient client, PresentationRequest
request) throws PresentationServerException
@@ -124,88 +116,31 @@
ContentAction contentAction = (ContentAction)objectAction;
//
- WindowNode targetWindow = (WindowNode)targetNode;
+ WindowNode window = (WindowNode)targetNode;
//
- PageNode page = (PageNode)targetWindow.getParent();
+ WindowNode.Content content = window.getContent();
//
- if (contentAction instanceof PortletContainerAction)
- {
- PortletContainerAction pcAction = (PortletContainerAction)contentAction;
+ String contentType = content.getType();
+ //
+ ContentHandler handler =
contentHandlerRegistry.getContentHandler(contentType);
- //
- PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
- client,
- page,
- portletInvoker);
+ //
+ ProtocolResponse response = handler.process(window, client, contentAction);
- PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
- portletControllerContext,
- client.getNavigationalStateContext(),
- PresentationPortletPageNavigationalState.CLONE_AND_WRITE_MODE);
+ //
+ if (response == null)
+ {
+ PageNode page = window.getPage();
//
- ControllerRequest controllerRequest;
- switch (pcAction.getPhase())
- {
- case ACTION:
- controllerRequest = new PortletActionRequest(
- pcAction.getTargetId(),
- pcAction.getState(),
- pcAction.getForm(),
-
pageNavigationalState.getPortletWindowNavigationalState(pcAction.getTargetId()),
- pageNavigationalState
- );
- break;
- case RENDER:
- PortletWindowNavigationalState windowNavigationalState = new
PortletWindowNavigationalState(
- pcAction.getState(),
- pcAction.getMode(),
- pcAction.getWindowState()
- );
- controllerRequest = new PortletRenderRequest(
- pcAction.getTargetId(),
- windowNavigationalState,
- null,
- pageNavigationalState
- );
- break;
- default:
- throw new NotYetImplemented();
- }
-
- //
- PortletController controller = new PortletController();
-
- //
- try
- {
- ControllerResponse response =
controller.process(portletControllerContext, controllerRequest);
-
- if (response instanceof PageUpdateResponse)
- {
- PageUpdateResponse pageUpdate = (PageUpdateResponse)response;
-
- //
- NavigationalStateContext nsc =
client.getNavigationalStateContext();
-
- //
- PresentationPortletPageNavigationalState blah =
(PresentationPortletPageNavigationalState)pageUpdate.getPageNavigationalState();
-
- //
- blah.flush();
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
-
- //
- return new PresentationResponse(new ShowUIObjectResponse(page.getId()));
+ response = new ShowUIObjectResponse(page.getId());
}
+
+ //
+ return new PresentationResponse(response);
}
}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandler.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * 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.presentation.portal.content;
+
+import org.jboss.portal.presentation.model.content.WindowContent;
+import org.jboss.portal.presentation.portal.model.WindowNode;
+import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.presentation.server.PresentationServerException;
+import org.jboss.portal.presentation.protocol.ProtocolAction;
+import org.jboss.portal.presentation.protocol.ProtocolResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ContentHandler
+{
+
+ ProtocolResponse process(WindowNode window, PresentationClient client, ContentAction
action) throws PresentationServerException;
+
+ WindowContent render(WindowNode window, PresentationClient client) throws
PresentationServerException;
+
+}
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandlerRegistry.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandlerRegistry.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/ContentHandlerRegistry.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * 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.presentation.portal.content;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ContentHandlerRegistry
+{
+
+ private final Map<String, ContentHandler> blah;
+
+ public ContentHandlerRegistry()
+ {
+ blah = new HashMap<String, ContentHandler>();
+ }
+
+ public void addContentHandler(String contentType, ContentHandler contentHandler)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (contentHandler == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (blah.containsKey(contentType))
+ {
+ throw new IllegalStateException("Content type " + contentType + "
already registered");
+ }
+ blah.put(contentType, contentHandler);
+ }
+
+ public void removeContentHandler(String contentType)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (blah.remove(contentType) == null)
+ {
+ throw new IllegalStateException("Content type " + contentType + "
is not registered");
+ }
+ }
+
+ public ContentHandler getContentHandler(String contentType)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return blah.get(contentType);
+ }
+}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java 2008-06-01
15:32:27 UTC (rev 10890)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContent.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -48,6 +48,11 @@
return markup;
}
+ public String getType()
+ {
+ return "markup";
+ }
+
public WindowContent render(WindowNode window, PresentationClient client,
PortletInvoker portletInvoker) throws PresentationServerException
{
return new WindowContent(0, "blah", "markup");
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/markup/MarkupContentHandler.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * 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.presentation.portal.content.markup;
+
+import org.jboss.portal.presentation.portal.content.ContentHandler;
+import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
+import org.jboss.portal.presentation.portal.model.WindowNode;
+import org.jboss.portal.presentation.model.content.WindowContent;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.presentation.server.PresentationServerException;
+import org.jboss.portal.presentation.protocol.ProtocolResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MarkupContentHandler implements ContentHandler
+{
+
+ public ProtocolResponse process(WindowNode window, PresentationClient client,
ContentAction action) throws PresentationServerException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public WindowContent render(WindowNode window, PresentationClient client) throws
PresentationServerException
+ {
+ String markup = ((MarkupContent)window.getContent()).getMarkup();
+ return new WindowContent(0, "blah", markup);
+ }
+}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java 2008-06-01
15:32:27 UTC (rev 10890)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContent.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -56,14 +56,15 @@
return ref;
}
+ public String getType()
+ {
+ return "portlet";
+ }
+
public WindowContent render(WindowNode window, PresentationClient client,
PortletInvoker portletInvoker) throws PresentationServerException
{
-
try
{
- NavigationalStateContext navigationalStateContext =
client.getNavigationalStateContext();
-
- //
PageNode page = (PageNode)window.getParent();
//
Added:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java
(rev 0)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/content/portlet/PortletContentHandler.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -0,0 +1,188 @@
+/******************************************************************************
+ * 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.presentation.portal.content.portlet;
+
+import org.jboss.portal.presentation.portal.content.ContentHandler;
+import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
+import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletControllerContext;
+import
org.jboss.portal.presentation.portal.content.portlet.controller.PresentationPortletPageNavigationalState;
+import
org.jboss.portal.presentation.portal.content.portlet.protocol.PortletContainerAction;
+import org.jboss.portal.presentation.portal.model.WindowNode;
+import org.jboss.portal.presentation.portal.model.PageNode;
+import org.jboss.portal.presentation.model.content.WindowContent;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.presentation.server.PresentationServerException;
+import org.jboss.portal.presentation.protocol.ProtocolResponse;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+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.PortletWindowNavigationalState;
+import org.jboss.portal.portlet.controller.request.ControllerRequest;
+import org.jboss.portal.portlet.controller.request.PortletActionRequest;
+import org.jboss.portal.portlet.controller.request.PortletRenderRequest;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.common.NotYetImplemented;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletContentHandler implements ContentHandler
+{
+
+ /** . */
+ private PortletInvoker portletInvoker;
+
+ public PortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public ProtocolResponse process(WindowNode window, PresentationClient client,
ContentAction action) throws PresentationServerException
+ {
+ PortletContainerAction pcAction = (PortletContainerAction)action;
+
+ //
+ PageNode page = window.getPage();
+
+ //
+ PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
+ client,
+ page,
+ portletInvoker);
+
+ PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
+ portletControllerContext,
+ client.getNavigationalStateContext(),
+ PresentationPortletPageNavigationalState.CLONE_AND_WRITE_MODE);
+
+ //
+ ControllerRequest controllerRequest;
+ switch (pcAction.getPhase())
+ {
+ case ACTION:
+ controllerRequest = new PortletActionRequest(
+ pcAction.getTargetId(),
+ pcAction.getState(),
+ pcAction.getForm(),
+
pageNavigationalState.getPortletWindowNavigationalState(pcAction.getTargetId()),
+ pageNavigationalState
+ );
+ break;
+ case RENDER:
+ PortletWindowNavigationalState windowNavigationalState = new
PortletWindowNavigationalState(
+ pcAction.getState(),
+ pcAction.getMode(),
+ pcAction.getWindowState()
+ );
+ controllerRequest = new PortletRenderRequest(
+ pcAction.getTargetId(),
+ windowNavigationalState,
+ null,
+ pageNavigationalState
+ );
+ break;
+ default:
+ throw new NotYetImplemented();
+ }
+
+ //
+ PortletController controller = new PortletController();
+
+ //
+ try
+ {
+ ControllerResponse response = controller.process(portletControllerContext,
controllerRequest);
+
+ if (response instanceof PageUpdateResponse)
+ {
+ PageUpdateResponse pageUpdate = (PageUpdateResponse)response;
+
+ //
+ NavigationalStateContext nsc = client.getNavigationalStateContext();
+
+ //
+ PresentationPortletPageNavigationalState blah =
(PresentationPortletPageNavigationalState)pageUpdate.getPageNavigationalState();
+
+ //
+ blah.flush();
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+
+ //
+ return null;
+ }
+
+ public WindowContent render(WindowNode window, PresentationClient client) throws
PresentationServerException
+ {
+ try
+ {
+ PageNode page = (PageNode)window.getParent();
+
+ //
+ PortletController controller = new PortletController();
+
+ //
+ PresentationPortletControllerContext portletControllerContext = new
PresentationPortletControllerContext(
+ client,
+ page,
+ portletInvoker);
+
+ //
+ PresentationPortletPageNavigationalState pageNavigationalState = new
PresentationPortletPageNavigationalState(
+ portletControllerContext,
+ client.getNavigationalStateContext(),
+ PresentationPortletPageNavigationalState.READ_ONLY_MODE);
+
+ PortletInvocationResponse response = controller.render(portletControllerContext,
null, pageNavigationalState, window.getId());
+
+ //
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ return new WindowContent(0, fragment.getTitle(), fragment.getContent());
+ }
+ else
+ {
+ return new WindowContent(0, "Unexpected response for window " +
window.getId(), "");
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ throw new PresentationServerException(e);
+ }
+ }
+}
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java 2008-06-01
15:32:27 UTC (rev 10890)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/WindowNode.java 2008-06-01
23:08:16 UTC (rev 10891)
@@ -76,5 +76,8 @@
public static abstract class Content
{
public abstract WindowContent render(WindowNode window, PresentationClient client,
PortletInvoker portletInvoker) throws PresentationServerException;
+
+ public abstract String getType();
+
}
}