Author: sohil.shah(a)jboss.com
Date: 2008-04-23 02:13:10 -0400 (Wed, 23 Apr 2008)
New Revision: 10698
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java
modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java
Modified:
modules/presentation/trunk/ajax/
modules/presentation/trunk/ajax/build.xml
modules/presentation/trunk/ajax/pom.xml
modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java
Log:
New Ajax User Agent Integration
Property changes on: modules/presentation/trunk/ajax
___________________________________________________________________
Name: svn:ignore
- target
+ target
.gwt-cache
Modified: modules/presentation/trunk/ajax/build.xml
===================================================================
--- modules/presentation/trunk/ajax/build.xml 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/build.xml 2008-04-23 06:13:10 UTC (rev 10698)
@@ -68,15 +68,19 @@
<lib file="${dependency.jboss-dependency.jar}"/>
<lib file="${dependency.jboss-common-core.jar}"/>
<lib file="${dependency.jboss.portal.common.mc.jar}"/>
+ <lib file="${dependency.jboss.portal.common.common.jar}"/>
+ <lib file="${dependency.jboss.portal.common.portal.jar}"/>
+ <lib file="${dependency.jboss.portal.web.jar}"/>
+ <lib file="${dependency.jboss.portal.portlet-jsr168api.jar}"/>
+ <lib file="${dependency.jboss.portal.portlet-portal.jar}"/>
<lib file="${dependency.gwt-user.jar}"/>
<lib file="${dependency.presentation.presentation.jar}"/>
- <lib file="${dependency.presentation.classic.jar}"/>
<lib file="${dependency.presentation.ajax.jar}"/>
<lib
file="${basedir}/target/presentation-mockportal-plugin.jar"/>
</war>
</target>
- <target name="install" description="Generate all target output and
deploy it to a locally setup app server" depends="package">
+ <target name="install" description="Generate all target output and
deploy it to a locally setup app server">
<copy file="${basedir}/target/presentation.war"
todir="${jboss.home}/server/${portal.deploy.dir}/deploy"
overwrite="true"/>
</target>
<!-- ================================================================== -->
Modified: modules/presentation/trunk/ajax/pom.xml
===================================================================
--- modules/presentation/trunk/ajax/pom.xml 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/pom.xml 2008-04-23 06:13:10 UTC (rev 10698)
@@ -18,14 +18,8 @@
<artifactId>presentation-presentation</artifactId>
<version>${project.version}</version>
</dependency>
-
+
<dependency>
- <groupId>org.jboss.portal.presentation</groupId>
- <artifactId>presentation-classic</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>sun-servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
@@ -133,9 +127,8 @@
</dependency>
</dependencies>
- <build>
- <plugins>
-<!--
+ <build>
+ <plugins>
<plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
@@ -161,30 +154,32 @@
</dependencies>
<executions>
<execution>
- <id>install</id>
- <phase>install</phase>
+ <id>package</id>
+ <phase>package</phase>
<configuration>
<tasks>
<property name="compile_classpath"
refid="maven.compile.classpath"/>
<property name="runtime_classpath"
refid="maven.runtime.classpath"/>
<property name="test_classpath"
refid="maven.test.classpath"/>
<property name="plugin_classpath"
refid="maven.plugin.classpath"/>
- <property name="project.version"
value="${project.version}"/>
- <property name="jboss.home"
value="${jboss.home}"/>
- <property name="portal.deploy.dir"
value="${portal.deploy.dir}"/>
+ <property name="project.version"
value="${project.version}"/>
<property name="dependency.gwt-user.jar"
value="${maven.dependency.com.google.gwt.gwt-user.jar.path}"/>
<property
name="dependency.jboss.portal.common.mc.jar"
value="${maven.dependency.org.jboss.portal.common.common-mc.jar.path}"/>
+ <property
name="dependency.jboss.portal.common.common.jar"
value="${maven.dependency.org.jboss.portal.common.common-common.jar.path}"/>
+ <property
name="dependency.jboss.portal.common.portal.jar"
value="${maven.dependency.org.jboss.portal.common.common-portal.jar.path}"/>
+ <property name="dependency.jboss.portal.web.jar"
value="${maven.dependency.org.jboss.portal.web.web-web.jar.path}"/>
+ <property
name="dependency.jboss.portal.portlet-jsr168api.jar"
value="${maven.dependency.org.jboss.portal.portlet.portlet-jsr168api.jar.path}"/>
+ <property
name="dependency.jboss.portal.portlet-portal.jar"
value="${maven.dependency.org.jboss.portal.portlet.portlet-portal.jar.path}"/>
<property name="dependency.jboss-kernel.jar"
value="${maven.dependency.org.jboss.microcontainer.jboss-kernel.jar.path}"/>
<property name="dependency.jboss-container.jar"
value="${maven.dependency.org.jboss.microcontainer.jboss-container.jar.path}"/>
<property name="dependency.jboss-dependency.jar"
value="${maven.dependency.org.jboss.microcontainer.jboss-dependency.jar.path}"/>
<property name="dependency.jboss-common-core.jar"
value="${maven.dependency.org.jboss.jboss-common-core.jar.path}"/>
<property name="dependency.presentation.ajax.jar"
value="${basedir}/target/presentation-ajax-${project.version}.jar"/>
- <property
name="dependency.presentation.presentation.jar"
value="${maven.dependency.org.jboss.portal.presentation.presentation-presentation.jar.path}"/>
- <property name="dependency.presentation.classic.jar"
value="${maven.dependency.org.jboss.portal.presentation.presentation-classic.jar.path}"/>
+ <property
name="dependency.presentation.presentation.jar"
value="${maven.dependency.org.jboss.portal.presentation.presentation-presentation.jar.path}"/>
<ant antfile="${basedir}/build.xml">
- <target name="install"/>
+ <target name="package"/>
</ant>
</tasks>
@@ -193,9 +188,29 @@
<goal>run</goal>
</goals>
</execution>
+
+ <!-- Used for deployment to a local application server during
Development. Hence commented out -->
+ <!--
+ <execution>
+ <id>install</id>
+ <phase>install</phase>
+ <configuration>
+ <tasks>
+ <property name="jboss.home"
value="${jboss.home}"/>
+ <property name="portal.deploy.dir"
value="${portal.deploy.dir}"/>
+ <ant antfile="${basedir}/build.xml">
+ <target name="install"/>
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ -->
+
</executions>
- </plugin>
--->
+ </plugin>
</plugins>
</build>
</project>
Modified: modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml 2008-04-23
06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml 2008-04-23
06:13:10 UTC (rev 10698)
@@ -31,7 +31,7 @@
</bean>
<bean
name="PresentationServer"
-
class="org.jboss.portal.presentation.impl.server.PresentationServerImpl">
+
class="org.jboss.portal.presentation.test.portal.PresentationServerImpl">
<constructor>
<parameter><inject
bean="StructuralStateContext"/></parameter>
</constructor>
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java 2008-04-23
06:05:47 UTC (rev 10697)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.presentation.ajax;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.URLFormat;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIWindow;
-import org.jboss.portal.presentation.classic.ClassicPresentationClient;
-import org.jboss.portal.presentation.classic.model.ClassicUINode;
-import org.jboss.portal.presentation.classic.model.ClassicViewPortContext;
-import org.jboss.portal.presentation.classic.model.DefaultPageViewPortScope;
-import org.jboss.portal.presentation.classic.model.PageViewPortScope;
+import org.jboss.portal.presentation.ajax.model.AjaxUINode;
+import org.jboss.portal.presentation.ajax.model.AjaxViewPortContext;
+import org.jboss.portal.presentation.ajax.model.PageViewPortScope;
+import org.jboss.portal.presentation.ajax.model.AjaxNavigationalStateContext;
import org.jboss.portal.presentation.impl.model.UIModelImpl;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.UIObject;
@@ -41,23 +43,39 @@
import org.jboss.portal.presentation.protocol.ProtocolAction;
import org.jboss.portal.presentation.protocol.ProtocolResponse;
import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
+import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
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.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.WebResponse;
+import org.jboss.portal.web.impl.DefaultServletContainerFactory;
+import org.jboss.portal.web.ServletContainer;
import java.io.IOException;
+import java.io.Writer;
import java.util.Collection;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class AjaxPresentationClient extends ClassicPresentationClient
-{
+public class AjaxPresentationClient implements PresentationClient
+{
+ /** . */
+ protected final WebRequest req;
+
+ /** . */
+ protected final WebResponse resp;
+
+ /** . */
+ protected final PresentationServer server;
+
/**
*
* @param request
@@ -69,59 +87,117 @@
WebResponse response,
PresentationServer server)
{
- super(request, response, server);
+ this.req = request;
+ this.resp = response;
+ this.server = server;
}
-
//---------------------------------------------------------------------------------------------------------------------------------------------------------
+ //---PresentationClient
implementation------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
*/
- public void process() throws IOException, PresentationServerException
+ public ServletContextDispatcher getDispatcher()
{
- ProtocolAction action =
(ProtocolAction)req.getAttribute("serverAction");
+ ServletContainer container =
DefaultServletContainerFactory.getInstance().getServletContainer();
+ return new ServletContextDispatcher(
+ req,
+ resp,
+ container);
+ }
- PresentationResponse presentationResp = null;
-
- if (action != null)
+ /**
+ *
+ */
+ public NavigationalStateContext getNavigationalStateContext()
+ {
+ NavigationalStateContext ajaxNavigationalStateContext =
(NavigationalStateContext)this.req.getSession().getAttribute(Constants.navigationalStateContext);
+
+ if(ajaxNavigationalStateContext == null)
{
- PresentationRequest request = new PresentationRequest(action);
-
- presentationResp = server.process(this, request);
+ ajaxNavigationalStateContext = new AjaxNavigationalStateContext();
+ this.req.getSession().setAttribute(Constants.navigationalStateContext,
ajaxNavigationalStateContext);
}
+
+ return ajaxNavigationalStateContext;
+ }
- if (presentationResp != null)
+ /**
+ *
+ */
+ public String renderURL(ProtocolAction action, URLFormat format) throws
IllegalArgumentException
+ {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public void renderURL(Writer writer, ProtocolAction action, URLFormat format) throws
IOException
+ {
+ }
+
+ /**
+ *
+ */
+ public void process() throws IOException, PresentationServerException
+ {
+ try
{
- ProtocolResponse protocolResp = presentationResp.getProtocolResponse();
-
- //
- if (protocolResp instanceof ShowUIObjectResponse)
+ ProtocolAction action =
(ProtocolAction)req.getAttribute(Constants.serverAction);
+ PresentationResponse presentationResp = null;
+
+ if (action != null)
{
- ShowUIObjectResponse showObjectResp = (ShowUIObjectResponse)protocolResp;
- PageViewPortScope scope = new
PageViewPortScope(showObjectResp.getTargetId());
- renderDocument(scope, showObjectResp.getTargetId());
+ PresentationRequest request = new PresentationRequest(action);
+
+ presentationResp = server.process(this, request);
}
+
+ if (presentationResp != null)
+ {
+ ProtocolResponse protocolResp = presentationResp.getProtocolResponse();
+
+ if(action instanceof ViewUIObjectAction)
+ {
+ req.setAttribute(Constants.forceRender, Boolean.TRUE);
+ }
+
+ //
+ if (protocolResp instanceof ShowUIObjectResponse)
+ {
+ ShowUIObjectResponse showObjectResp = (ShowUIObjectResponse)protocolResp;
+ PageViewPortScope scope = new
PageViewPortScope(showObjectResp.getTargetId());
+ prepareRPCResponse(scope, showObjectResp.getTargetId());
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Not handled: " +
protocolResp);
+ }
+ }
else
{
- throw new UnsupportedOperationException("Not handled: " +
protocolResp);
+ //Show the default Portal Page
+ StructuralStateContext ssc = server.getStructuralStateContext();
+ PageViewPortScope scope = new PageViewPortScope(ssc.getRootId());
+ req.setAttribute(Constants.forceRender, Boolean.TRUE);
+ prepareRPCResponse(scope, ssc.getRootId());
}
}
- else
+ finally
{
- StructuralStateContext ssc = server.getStructuralStateContext();
- DefaultPageViewPortScope scope = new DefaultPageViewPortScope(ssc.getRootId());
- renderDocument(scope, ssc.getRootId());
+
((AjaxNavigationalStateContext)this.getNavigationalStateContext()).clearStaleState();
}
- }
-
+ }
+
//----------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
* @param scope
* @param nodeId
* @throws IOException
*/
- private void renderDocument(ViewPortScope scope, String nodeId) throws IOException
+ private void prepareRPCResponse(ViewPortScope scope, String nodeId) throws
IOException
{
StructuralStateContext ssc = server.getStructuralStateContext();
- ClassicViewPortContext context = new ClassicViewPortContext();
+ AjaxViewPortContext context = new AjaxViewPortContext();
UIModel model = new UIModelImpl(null, ssc);
ViewPort viewPort = model.createViewPort(context, scope);
@@ -129,7 +205,7 @@
viewPort.refresh();
//
- ClassicUINode node = context.getNode(nodeId);
+ AjaxUINode node = context.getNode(nodeId);
//
renderNode(node);
@@ -139,7 +215,7 @@
*
* @param node
*/
- private void renderNode(ClassicUINode node)
+ private void renderNode(AjaxUINode node)
{
UIObject object = node.getObject();
@@ -150,12 +226,12 @@
}
else if (object instanceof UIPage)
{
- AjaxUIPage clientPage =
(AjaxUIPage)this.req.getAttribute("uiObject");
+ AjaxUIPage clientPage = (AjaxUIPage)this.req.getAttribute(Constants.uiObject);
if(clientPage == null)
{
clientPage = new AjaxUIPage();
clientPage.setId(object.getId());
- this.req.setAttribute("uiObject", clientPage);
+ this.req.setAttribute(Constants.uiObject, clientPage);
}
if (node.getChildren() != null)
@@ -165,28 +241,37 @@
}
else if (object instanceof UIWindow)
{
- AjaxUIPage clientPage =
(AjaxUIPage)this.req.getAttribute("uiObject");
- UIWindow window = (UIWindow)object;
+ AjaxUIPage clientPage = (AjaxUIPage)this.req.getAttribute(Constants.uiObject);
+ AjaxNavigationalStateContext navState =
(AjaxNavigationalStateContext)this.getNavigationalStateContext();
try
{
- WindowContent content = server.renderWindow(this, object.getId());
+ AjaxUIWindow clientWindow = new AjaxUIWindow();
- AjaxUIWindow clientWindow = new AjaxUIWindow();
+ if(navState.isStale(object.getId()) ||
this.req.getAttribute(Constants.forceRender)!=null)
+ {
+ WindowContent content = server.renderWindow(this, object.getId());
+ clientWindow.setContent(content.getMarkup());
+ }
+
clientWindow.setId(object.getId());
clientWindow.setParent(clientPage);
- clientPage.getChildren().add(clientWindow);
+ clientPage.getChildren().add(clientWindow);
- clientWindow.setContent(content.getMarkup());
+ WindowState windowState =
(WindowState)this.getNavigationalStateContext().getProperty(object.getId(),
Constants.windowState);
+ if(windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ this.getNavigationalStateContext().setProperty(object.getId(),
Constants.windowState, windowState);
+ }
+ clientWindow.setState(windowState.toString().toLowerCase());
- //TODO: remove hardcoding
- clientWindow.setState(AjaxUIWindow.NORMAL);
-
- //TODO: remove hard coding
- clientWindow.setMode(AjaxUIWindow.VIEW);
-
-
- //Restore the Status of the Window
- clientWindow.setStatus(AjaxUIWindow.STATUS_VALID);
+ Mode mode =
(Mode)this.getNavigationalStateContext().getProperty(object.getId(), Constants.mode);
+ if(mode == null)
+ {
+ mode = Mode.VIEW;
+ this.getNavigationalStateContext().setProperty(object.getId(),
Constants.mode, mode);
+ }
+ clientWindow.setMode(mode.toString().toLowerCase());
}
catch (PresentationServerException e)
{
@@ -199,17 +284,17 @@
*
* @param node
*/
- private void renderChildren(ClassicUINode node)
+ private void renderChildren(AjaxUINode node)
{
- Collection<ClassicUINode> children = node.getChildren();
+ Collection<AjaxUINode> children = node.getChildren();
//
if (children != null)
{
- for (ClassicUINode child : children)
+ for (AjaxUINode child : children)
{
renderNode(child);
}
}
- }
+ }
}
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java
(rev 0)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.ajax;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface Constants
+{
+ public String navigationalStateContext = "navigationalStateContext";
+ public String serverAction = "serverAction";
+ public String uiObject = "uiObject";
+ public String windowState = "windowstate";
+ public String mode = "mode";
+ public String forceRender = "forceRender";
+}
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java
(rev 0)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.ajax.model;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
+import org.jboss.portal.presentation.state.StateChangeVetoException;
+import org.jboss.portal.presentation.state.StateException;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AjaxNavigationalStateContext extends NavigationalStateContextImpl
+{
+ /**
+ *
+ */
+ private List<String> staleObjects = new ArrayList<String>();
+
+ /**
+ *
+ * @param objectId
+ * @return
+ */
+ public boolean isStale(String objectId)
+ {
+ boolean isStale = false;
+
+ if(this.staleObjects.contains(objectId))
+ {
+ isStale = true;
+ }
+
+ return isStale;
+ }
+
+ /**
+ *
+ * @param objectId
+ */
+ public void markAsStale(String objectId)
+ {
+ this.staleObjects.add(objectId);
+ }
+
+ /**
+ *
+ *
+ */
+ public void clearStaleState()
+ {
+ this.staleObjects.clear();
+ }
+ //-----Overriden
methods-----------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void setProperty(String objectId, String key, Object navigationalState)
+ throws StateChangeVetoException, StateException, IllegalArgumentException
+ {
+ this.markAsStale(objectId);
+
+ if(!key.equals("stale"))
+ {
+ super.setProperty(objectId, key, navigationalState);
+ }
+ }
+}
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java
(rev 0)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.ajax.model;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.jboss.portal.presentation.model.UIObject;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AjaxUINode
+{
+ /** . */
+ private final UIObject object;
+
+ /** . */
+ AjaxUINode parent = null;
+
+ /** . */
+ Map<String, AjaxUINode> children;
+
+ /**
+ *
+ * @param object
+ */
+ public AjaxUINode(UIObject object)
+ {
+ this.object = object;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public AjaxUINode getParent()
+ {
+ return parent;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getId()
+ {
+ return object.getId();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getName()
+ {
+ return object.getName();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public UIObject getObject()
+ {
+ return object;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Collection<AjaxUINode> getChildren()
+ {
+ return children == null ? null : children.values();
+ }
+}
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java
(rev 0)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.ajax.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.ViewPortContext;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AjaxViewPortContext implements ViewPortContext
+{
+ /**
+ *
+ */
+ final Map<String, AjaxUINode> nodes = new HashMap<String, AjaxUINode>();
+
+ /**
+ *
+ * @param nodeId
+ * @return
+ */
+ public AjaxUINode getNode(String nodeId)
+ {
+ return nodes.get(nodeId);
+ }
+
+ /**
+ *
+ */
+ public UIObject getObject(String objectId)
+ {
+ AjaxUINode node = nodes.get(objectId);
+
+ //
+ if (node == null)
+ {
+ return null;
+ }
+ else
+ {
+ return node.getObject();
+ }
+ }
+
+ /**
+ *
+ */
+ public void addObject(UIObject object)
+ {
+ AjaxUINode node = new AjaxUINode(object);
+
+ //
+ nodes.put(node.getId(), node);
+ }
+
+ /**
+ *
+ */
+ public void updateObject(String objectId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public void removeObject(String objectId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public void createChildren(String parentId)
+ {
+ nodes.get(parentId).children = new HashMap<String, AjaxUINode>();
+ }
+
+ /**
+ *
+ */
+ public void destroyChildren(String parentId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public void addChild(String parentId, String childId)
+ {
+ AjaxUINode parent = nodes.get(parentId);
+ AjaxUINode child = nodes.get(childId);
+
+ //
+ parent.children.put(child.getName(), child);
+ child.parent = parent;
+ }
+
+ /**
+ *
+ */
+ public void removeChild(String parentId, String childId)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java
(rev 0)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -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.presentation.ajax.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.ViewPortScope;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.model.ui.UIWindow;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ *
+ * @version $Revision: 630 $
+ */
+public class PageViewPortScope implements ViewPortScope
+{
+
+ /** . */
+ private static final int NO_PAGE = 0;
+
+ /** . */
+ private static final int PAGE = 1;
+
+ /** . */
+ private static final int PAGE_CHILD = 2;
+
+ /** . */
+ private static final int PAGE_SIBLING = 3;
+
+ /** . */
+ private final String pageId;
+
+ /** . */
+ private int pageStatus;
+
+ public PageViewPortScope(String pageId)
+ {
+ this.pageId = pageId;
+ this.pageStatus = 0;
+ }
+
+ public String getRootId()
+ {
+ return pageId;
+ }
+
+ public ObjectTraversalType enterObject(UIObject object)
+ {
+ if (object instanceof UIPage)
+ {
+ switch (pageStatus)
+ {
+ case NO_PAGE:
+ if (pageId.equals(object.getId()) ||
"default".equals(object.getName()))
+ {
+ pageStatus = PAGE;
+
+ // We want to traverse the children of the page currently being
displayed
+ return ObjectTraversalType.RECURSIVE;
+ }
+ else
+ {
+ pageStatus = PAGE_SIBLING;
+
+ // We want to see the sibbling pages of the page currently being
displayed
+ return ObjectTraversalType.SINGLE;
+ }
+ case PAGE:
+ pageStatus = PAGE_CHILD;
+
+ // We want to see the children pages of the page currently being
displayed
+ return ObjectTraversalType.SINGLE;
+ case PAGE_CHILD:
+ case PAGE_SIBLING:
+ return ObjectTraversalType.SKIP;
+ default:
+ throw new AssertionError();
+ }
+ }
+ else if (object instanceof UIWindow)
+ {
+ // We don't traverse windows (for now as they are supposed to be leaves)
+ return ObjectTraversalType.SINGLE;
+ }
+ else if (object instanceof UIContext)
+ {
+ return ObjectTraversalType.RECURSIVE;
+ }
+ else
+ {
+ return ObjectTraversalType.SKIP;
+ }
+ }
+
+ public void leaveObject(UIObject object)
+ {
+ if (object instanceof UIPage)
+ {
+ switch (pageStatus)
+ {
+ case NO_PAGE:
+ throw new AssertionError();
+ case PAGE:
+ pageStatus = NO_PAGE;
+ break;
+ case PAGE_SIBLING:
+ pageStatus = NO_PAGE;
+ break;
+ case PAGE_CHILD:
+ pageStatus = PAGE;
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-04-23
06:05:47 UTC (rev 10697)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -6,6 +6,7 @@
import org.apache.log4j.Logger;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.presentation.ajax.AjaxPresentationClient;
+import org.jboss.portal.presentation.ajax.Constants;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
import org.jboss.portal.presentation.ajax.client.protocol.AjaxShowUIObjectResponse;
import org.jboss.portal.presentation.ajax.client.protocol.ClientResponse;
@@ -99,18 +100,18 @@
HttpServletRequest request = this.getThreadLocalRequest();
- Object pendingServerAction =
request.getSession().getAttribute("serverAction");
+ Object pendingServerAction =
request.getSession().getAttribute(Constants.serverAction);
if(pendingServerAction != null)
{
- request.setAttribute("serverAction", pendingServerAction);
- request.getSession().removeAttribute("serverAction");
+ request.setAttribute(Constants.serverAction, pendingServerAction);
+ request.getSession().removeAttribute(Constants.serverAction);
}
//execute the call on the Portal
this.callPortalServer();
//Setup the initial UIContext for the client session
- AjaxUIObject uiObject =
(AjaxUIObject)request.getAttribute("uiObject");
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute(Constants.uiObject);
if(uiObject != null)
{
clientResponse = new AjaxShowUIObjectResponse(uiObject);
@@ -146,13 +147,13 @@
GetActivation get = new GetActivation(targetId, null, queryParams);
- request.setAttribute("serverAction", get);
+ request.setAttribute(Constants.serverAction, get);
//execute the call on the Portal
this.callPortalServer();
//Setup the initial UIContext for the client session
- AjaxUIObject uiObject =
(AjaxUIObject)request.getAttribute("uiObject");
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute(Constants.uiObject);
if(uiObject != null)
{
clientResponse = new AjaxShowUIObjectResponse(uiObject);
@@ -200,13 +201,13 @@
PostActivation post = new PostActivation(targetId, null, queryParams, null);
- request.setAttribute("serverAction", post);
+ request.setAttribute(Constants.serverAction, post);
//execute the call on the Portal
this.callPortalServer();
//Setup the initial UIContext for the client session
- AjaxUIObject uiObject =
(AjaxUIObject)request.getAttribute("uiObject");
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute(Constants.uiObject);
if(uiObject != null)
{
clientResponse = new AjaxShowUIObjectResponse(uiObject);
@@ -275,9 +276,6 @@
{
HttpServletRequest req = this.getThreadLocalRequest();
HttpServletResponse resp = this.getThreadLocalResponse();
-
-// WebRequest webReq = new WebRequest(req);
-// WebResponse webResp = new WebResponse(resp);
AjaxPresentationClient client = new AjaxPresentationClient(new AjaxRequest(req),
new AjaxResponse(resp), this.server);
client.process();
Added:
modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java
===================================================================
---
modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java
(rev 0)
+++
modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -0,0 +1,177 @@
+/******************************************************************************
+ * 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.test.portal;
+
+import java.util.Map;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.presentation.impl.state.structural.StructuralNode;
+import org.jboss.portal.presentation.impl.state.structural.StructuralStateContextImpl;
+import org.jboss.portal.presentation.impl.state.structural.WindowNode;
+import org.jboss.portal.presentation.model.content.WindowContent;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.protocol.ErrorResponse;
+import org.jboss.portal.presentation.protocol.ProtocolAction;
+import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
+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.PostActivation;
+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.web.Body;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PresentationServerImpl implements PresentationServer
+{
+
+ /** . */
+ private StructuralStateContextImpl structuralStateContext;
+
+ public PresentationServerImpl(StructuralStateContextImpl structuralStateContext)
+ {
+ this.structuralStateContext = structuralStateContext;
+ }
+
+ public StructuralStateContext getStructuralStateContext()
+ {
+ return structuralStateContext;
+ }
+
+ public String render(ProtocolAction action) throws IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public WindowContent renderWindow(PresentationClient client, String windowId) throws
PresentationServerException
+ {
+ StructuralNode node = structuralStateContext.getNode(windowId);
+
+ //
+ if (node instanceof WindowNode)
+ {
+ WindowNode window = (WindowNode)node;
+ return new WindowContent(0, "Window " + window.getName(),
window.getContent());
+ }
+ else
+ {
+ throw new PresentationServerException("No such window " + windowId);
+ }
+ }
+
+ /**
+ *
+ */
+ public PresentationResponse process(PresentationClient client, PresentationRequest
request) throws PresentationServerException
+ {
+ ProtocolAction action = request.getProtocolAction();
+
+ if (action instanceof UIObjectAction)
+ {
+ UIObjectAction objectAction = (UIObjectAction)action;
+
+ //
+ String targetId = objectAction.getTargetId();
+
+ //
+ StructuralNode targetNode = structuralStateContext.getNode(targetId);
+
+ //
+ if (targetNode == null)
+ {
+ return new PresentationResponse(new ErrorResponse(404));
+ }
+
+ //
+ if (objectAction instanceof ViewUIObjectAction)
+ {
+ return new PresentationResponse(new ShowUIObjectResponse(targetId));
+ }
+ else if(action instanceof LinkActivation)
+ {
+ return this.processLinkActivation(client, targetNode,
(LinkActivation)action);
+ }
+ }
+
+ //
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @param activation
+ * @return
+ */
+ private PresentationResponse processLinkActivation(PresentationClient client,
StructuralNode targetNode, LinkActivation activation)
+ {
+ PresentationResponse response = null;
+ NavigationalStateContext navState = client.getNavigationalStateContext();
+
+ //Get form parameters if any
+ Map formParameters = null;
+ if (activation instanceof PostActivation)
+ {
+ PostActivation post = (PostActivation)activation;
+ Body body = post.getBody();
+ if (body instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)body).getParameters();
+ }
+ }
+
+ WindowState windowState = activation.getWindowState();
+ Mode windowMode = activation.getWindowMode();
+
+ //Perform processing of this request through to the PortletContainer
+ //Just Stub code...just mark all children on this page as stale for re-rendering
+ for(StructuralNode window: targetNode.getParent().getChildren())
+ {
+ //TODO: need to finalize proper way to designate staleness of a window
+ //This matters to the ajax client, and not really to the classic client
+ //since classic client does a full refresh regardless
+ //Probably one way to signify staleness of window content requiring a rendering
+ //in a client agnostic manner....Still not sure about this one
+ navState.setProperty(window.getId(), "stale", Boolean.TRUE);
+ }
+
+ //Success so update the corresponding UI objects
+ navState.setProperty(targetNode.getId(), "windowstate", windowState);
+ navState.setProperty(targetNode.getId(), "mode", windowMode);
+
+ //Select the proper response
+ response = new PresentationResponse(new
ShowUIObjectResponse(targetNode.getParent().getId()));
+
+ return response;
+ }
+}
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java 2008-04-23
06:05:47 UTC (rev 10697)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java 2008-04-23
06:13:10 UTC (rev 10698)
@@ -24,6 +24,9 @@
import java.util.Map;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
* @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
@@ -77,4 +80,54 @@
{
return queryParameters;
}
+
+ /**
+ *
+ * @return
+ */
+ public WindowState getWindowState()
+ {
+ WindowState windowState = null;
+
+ if(this.queryParameters != null)
+ {
+ String[] windowStateValue = this.queryParameters.get("windowstate");
+ if(windowStateValue != null)
+ {
+ windowState = WindowState.create(windowStateValue[0]);
+ }
+ }
+
+ if(windowState == null)
+ {
+ windowState = windowState.NORMAL;
+ }
+
+ return windowState;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Mode getWindowMode()
+ {
+ Mode mode = null;
+
+ if(this.queryParameters != null)
+ {
+ String[] modeValue = this.queryParameters.get("mode");
+ if(modeValue != null)
+ {
+ mode = Mode.create(modeValue[0]);
+ }
+ }
+
+ if(mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+
+ return mode;
+ }
}