Author: julien(a)jboss.com
Date: 2007-11-29 08:30:41 -0500 (Thu, 29 Nov 2007)
New Revision: 9195
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java
Removed:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/state/content/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java
Log:
- don't consider content as a state scope type of the model as it is something that
can be regenerated and is up to the client nature to manage it
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java
===================================================================
---
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/server/PresentationServerImpl.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -26,7 +26,7 @@
import org.jboss.portal.presentation.server.Processor;
import org.jboss.portal.presentation.server.PresentationServer;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
+import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
import org.jboss.portal.core.controller.ControllerResponse;
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/UIController.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -24,11 +24,10 @@
import org.jboss.portal.presentation.client.PresentationContext;
import org.jboss.portal.presentation.impl.PresentationContextImpl;
-import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
+import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.protocol.GetActivation;
import org.jboss.portal.presentation.protocol.PostActivation;
import org.jboss.portal.presentation.protocol.ServerAction;
@@ -62,16 +61,11 @@
*/
public class UIController implements RequestController
{
- /**
- *
- */
+
+ /** . */
private PresentationServer presentationServer = null;
- /**
- *
- *
- */
public UIController()
{
}
@@ -80,7 +74,6 @@
/**
* handle is the entry point for handling an incoming Portal request. The request is
handed over
* from the Http Layer via the main Portal Servlet
- *
*/
public void handle(ServerInvocation invocation) throws ServerException
{
@@ -131,34 +124,10 @@
//Load the objects in the UITree
UIObject uiObject = presentationContext.getUIContext().getObject(targetId);
-
+
if(uiObject instanceof UIPage)
{
- UIPage page = (UIPage)uiObject;
- //Populate the state of the Windows in the Page that is being displayed
- //inside the UITree
- List<UIObject> windows = page.getChildren();
- if(windows != null)
- {
- for(int i=0; i<windows.size(); i++)
- {
- UIObject cour = windows.get(i);
-
- if(cour instanceof UIWindow)
- {
- UIWindow window = (UIWindow)cour;
- WindowContent windowContent =
this.presentationServer.render(presentationContext, window);
-
- /**
- * TODO: decouple this from the model implementation by moving
the functinality
- * to another component like a UIPresenter etc
- */
- ((org.jboss.portal.presentation.impl.model.UIWindowImpl)window).
- setContent(windowContent);
- }
- }
- }
- this.render(response.getWriter(), presentationContext.getUIContext(),
targetId);
+ render(response.getWriter(), presentationContext, targetId);
}
}
}
@@ -358,10 +327,10 @@
* TODO: this should be used only in classic UI case...eventually when Controller is
abstracted, this will be moved to
* the ClassicController implementation
*/
- private void render(PrintWriter clientConnection, UIContext uiContext, String
targetId)
+ private void render(PrintWriter clientConnection, PresentationContext
presentationContext, String targetId)
{
StringBuffer responseBuffer = new StringBuffer();
- UIObject uiObject = (UIObject)uiContext.getObject(targetId);
+ UIObject uiObject = presentationContext.getUIContext().getObject(targetId);
//Display the page to the client
if(uiObject instanceof UIPage)
@@ -373,14 +342,20 @@
UIObject cour = windows.get(i);
if(cour instanceof UIWindow)
{
- org.jboss.portal.presentation.impl.model.UIWindowImpl window =
(org.jboss.portal.presentation.impl.model.UIWindowImpl)cour;
- if(window.getContent() != null)
+ UIWindow window = (UIWindow)cour;
+
+ try
{
+ WindowContent windowContent =
this.presentationServer.render(presentationContext, window);
responseBuffer.append("<div>");
- responseBuffer.append("<div
id=\"title\">"+window.getContent().getTitle()+"</div>");
- responseBuffer.append("<div
id=\"content\">"+window.getContent().getMarkup()+"</div>");
+ responseBuffer.append("<div
id=\"title\">").append(windowContent.getTitle()).append("</div>");
+ responseBuffer.append("<div
id=\"content\">").append(windowContent.getMarkup()).append("</div>");
responseBuffer.append("</div><br/><br/>");
}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
}
}
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -24,11 +24,9 @@
import org.jboss.portal.presentation.client.PresentationContext;
import org.jboss.portal.presentation.impl.model.UIContextImpl;
-import org.jboss.portal.presentation.impl.model.state.content.ContentStateContextImpl;
import
org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.model.UIContext;
import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.state.content.ContentStateContext;
import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.protocol.LinkActivation;
import org.jboss.portal.presentation.protocol.ServerAction;
@@ -82,15 +80,7 @@
}
//
- ContentStateContext csc =
(ContentStateContext)session.getAttribute("csc");
- if (csc == null)
- {
- csc = new ContentStateContextImpl();
- session.setAttribute("csc", csc);
- }
-
- //
- root = new UIContextImpl(presentationServer.getStructuralStateManager(), nsc,
csc);
+ root = new UIContextImpl(presentationServer.getStructuralStateManager(), nsc);
}
//
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIContextImpl.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -30,7 +30,6 @@
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIPortal;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.ContentStateContext;
import org.jboss.portal.presentation.model.state.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
@@ -57,9 +56,6 @@
protected final NavigationalStateContext navigationalStateContext;
/** . */
- protected final ContentStateContext contentStateContext;
-
- /** . */
protected final List<ModelListener> listeners;
private static String getRootId(StructuralStateContext loader)
@@ -74,15 +70,13 @@
public UIContextImpl(
StructuralStateContext structuralStateContext,
- NavigationalStateContext navigationalStateContext,
- ContentStateContext contentStateContext)
+ NavigationalStateContext navigationalStateContext)
{
super(getRootId(structuralStateContext), getRootState(structuralStateContext));
//
this.structuralStateContext = structuralStateContext;
this.navigationalStateContext = navigationalStateContext;
- this.contentStateContext = contentStateContext;
this.listeners = new ArrayList<ModelListener>();
// Put our self in the object cache
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -127,9 +127,6 @@
Object value;
switch (scopeType)
{
- case CONTENT:
- value = context.contentStateContext.get(id, propertyName);
- break;
case NAVIGATIONAL:
value = context.navigationalStateContext.get(id, propertyName);
break;
@@ -159,9 +156,6 @@
}
switch (scopeType)
{
- case CONTENT:
- context.contentStateContext.set(id, propertyName, propertyValue);
- break;
case NAVIGATIONAL:
context.navigationalStateContext.set(id, propertyName, propertyValue);
break;
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIWindowImpl.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -27,7 +27,6 @@
import org.jboss.portal.presentation.model.StateScopeType;
import org.jboss.portal.presentation.model.UIObject;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
/**
@@ -42,16 +41,6 @@
super(context, id, state);
}
- public WindowContent getContent()
- {
- return getProperty(StateScopeType.CONTENT, "content",
WindowContent.class);
- }
-
- public void setContent(WindowContent windowContent)
- {
- setProperty(StateScopeType.CONTENT, "content", windowContent);
- }
-
/**
*
*/
@@ -74,7 +63,6 @@
public void setMode(Mode mode)
{
setProperty(StateScopeType.NAVIGATIONAL, "mode", mode);
- setProperty(StateScopeType.CONTENT, "content", null);
}
/**
@@ -83,7 +71,6 @@
public void setWindowState(WindowState windowState)
{
setProperty(StateScopeType.NAVIGATIONAL, "windowstate", windowState);
- setProperty(StateScopeType.CONTENT, "content", null);
}
public Object getContentState()
@@ -94,7 +81,6 @@
public void setContentState(Object contentState)
{
setProperty(StateScopeType.NAVIGATIONAL, "content", contentState);
- setProperty(StateScopeType.CONTENT, "content", null);
}
/**
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/StateScopeType.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -29,12 +29,6 @@
public enum StateScopeType
{
/**
- * The content scope type. The content scope defines state which can be stored in the
model for convenience but can
- * always be computed again.
- */
- CONTENT,
-
- /**
* The navigational scope type. The navigational scope describe the a kind of change
done at runtime by the user when it
* interacts with the model (i.e not all interactions with the model are automatically
navigational state changes).
*/
Copied:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java
(from rev 9129,
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/content/WindowContent.java)
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/content/WindowContent.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 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.model.content;
+
+/**
+ * The content of a window.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WindowContent
+{
+
+ /** . */
+ private final long expirationMillis;
+
+ /** . */
+ private final String title;
+
+ /** . */
+ private final String markup;
+
+
+ public WindowContent(long expirationMillis, String title, String markup)
+ {
+ this.expirationMillis = expirationMillis;
+ this.title = title;
+ this.markup = markup;
+ }
+
+ public long getExpirationMillis()
+ {
+ return expirationMillis;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public String getMarkup()
+ {
+ return markup;
+ }
+}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/server/PresentationServer.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -24,7 +24,7 @@
import org.jboss.portal.presentation.client.PresentationContext;
import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.content.WindowContent;
+import org.jboss.portal.presentation.model.content.WindowContent;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
/**
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/ModelTestCase.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -26,7 +26,6 @@
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.jboss.portal.presentation.impl.model.UIContextImpl;
-import org.jboss.portal.presentation.impl.model.state.content.ContentStateContextImpl;
import
org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.model.StateScopeType;
import org.jboss.portal.presentation.model.UIContext;
@@ -34,8 +33,6 @@
import org.jboss.portal.presentation.model.UIPage;
import org.jboss.portal.presentation.model.UIPortal;
import org.jboss.portal.presentation.model.state.NoSuchStateException;
-import org.jboss.portal.presentation.model.state.StateChange;
-import org.jboss.portal.presentation.model.state.StateChangeEvent;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
@@ -172,7 +169,7 @@
private UIContext createContext()
{
- return new UIContextImpl(model.getStructuralStateContext(), new
NavigationalStateContextImpl(), new ContentStateContextImpl());
+ return new UIContextImpl(model.getStructuralStateContext(), new
NavigationalStateContextImpl());
}
public void testGetPropertyThrowsIAE()
@@ -273,11 +270,6 @@
assertEquals(StateScopeType.NAVIGATIONAL, propertyName, propertyValue,
propertyClass);
}
- <T> void assertContentEquals(String propertyName, T propertyValue,
Class<T> propertyClass)
- {
- assertEquals(StateScopeType.CONTENT, propertyName, propertyValue,
propertyClass);
- }
-
<T> void assertEquals(StateScopeType scopeType, String propertyName, T
propertyValue, Class<T> propertyClass)
{
Assert.assertEquals(propertyValue, object.getProperty(scopeType, propertyName,
propertyClass));
@@ -444,25 +436,6 @@
eventAssert.assertEmpty();
}
- public void testUpdateContentProperty()
- {
- MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
- UIContext context = createContext();
-
- // Check initial state
- UIPortal foo = (UIPortal)context.getObject(mockFoo.getId());
- PropertyAssert fooAssert = new PropertyAssert(foo);
- fooAssert.assertContentEquals("foo", null, String.class);
-
- // Update content state
- foo.setProperty(StateScopeType.CONTENT, "foo",
"foo_new_value");
- fooAssert.assertContentEquals("foo", "foo_new_value",
String.class);
-
- // Update content state
- foo.setProperty(StateScopeType.CONTENT, "foo", 2);
- fooAssert.assertContentEquals("foo", 2, Integer.class);
- }
-
public void testUpdateNavigationalProperty()
{
MockObject mockFoo = model.getRoot().addChild("foo",
MockObject.Type.PORTAL);
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java 2007-11-29
13:16:38 UTC (rev 9194)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java 2007-11-29
13:30:41 UTC (rev 9195)
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.jboss.portal.presentation.impl.model.UIContextImpl;
-import org.jboss.portal.presentation.impl.model.state.content.ContentStateContextImpl;
import
org.jboss.portal.presentation.impl.model.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.model.UIContext;
@@ -43,7 +42,7 @@
*/
protected void setUp() throws Exception
{
- this.uiContext = new UIContextImpl(new MockModel().getStructuralStateContext(), new
NavigationalStateContextImpl(), new ContentStateContextImpl());
+ this.uiContext = new UIContextImpl(new MockModel().getStructuralStateContext(), new
NavigationalStateContextImpl());
}
/**