JBoss Portal SVN: r6905 - in trunk: core/src/main/org/jboss/portal/core/impl and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-03 08:18:06 -0400 (Tue, 03 Apr 2007)
New Revision: 6905
Added:
trunk/core/src/main/org/jboss/portal/core/impl/theme/
trunk/theme/src/main/org/jboss/portal/theme/render/ActionRenderContext.java
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java
trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java
Log:
introduced ActionRenderContext to decouple totally XXXRender from the implementations since it was still using WindowResult.Action
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -124,7 +124,7 @@
rendition.getPageResult().addWindowResult("BLAH", res);
//
- Region region = rendition.getPageResult().getRegion("navigation");
+ Region region = rendition.getPageResult().getRegion2("navigation");
region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
}
}
@@ -143,7 +143,7 @@
rendition.getPageResult().addWindowResult("BLUH", res);
//
- Region region = rendition.getPageResult().getRegion("dashboardnav");
+ Region region = rendition.getPageResult().getRegion2("dashboardnav");
region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -57,6 +57,7 @@
import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.render.ActionRenderContext;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.Exceptions;
@@ -309,8 +310,8 @@
windowTitle = "Portlet unavailable";
contentChars = "Portlet unavailable";
actionMap = new HashMap();
- actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
- actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(ActionRenderContext.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(ActionRenderContext.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
@@ -332,8 +333,8 @@
}
if (RenderWindowCommand.SHOW.equals(cfg.getProperty(RenderWindowCommand.WINDOW_ACCESS_DENIED)))
{
- actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
- actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(ActionRenderContext.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(ActionRenderContext.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Access denied";
contentChars = "Access denied";
return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
@@ -347,8 +348,8 @@
}
if (RenderWindowCommand.SHOW.equals(cfg.getProperty(RenderWindowCommand.WINDOW_NOT_FOUND)))
{
- actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
- actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(ActionRenderContext.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(ActionRenderContext.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Cannot render";
contentChars = "Object not found " + e.getRef();
return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
@@ -392,10 +393,10 @@
WindowState windowState = (WindowState)j.next();
String url = createUpdateNavigationalStateURL(context, window, null, windowState);
boolean disabled = windowState.equals(currentWindowState);
- WindowResult.Action action = new WindowResult.Action(windowState, url, !disabled);
+ WindowResult.Action action = new WindowResult.Action(windowState.toString(), url, !disabled);
windowStates.add(action);
}
- actionMap.put(WindowResult.WINDOWSTATES_KEY, windowStates);
+ actionMap.put(ActionRenderContext.WINDOWSTATES_KEY, windowStates);
}
/**
@@ -410,10 +411,10 @@
Mode mode = (Mode)j.next();
String url = createUpdateNavigationalStateURL(context, window, mode, null);
boolean disabled = mode.equals(currentMode);
- WindowResult.Action action = new WindowResult.Action(mode, url, !disabled);
+ WindowResult.Action action = new WindowResult.Action(mode.toString(), url, !disabled);
modes.add(action);
}
- actionMap.put(WindowResult.MODES_KEY, modes);
+ actionMap.put(ActionRenderContext.MODES_KEY, modes);
}
private String createUpdateNavigationalStateURL(ControllerContext context, Window window, Mode mode, WindowState windowState)
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -24,11 +24,11 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.render.DecorationRenderer;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.render.DecorationRenderContext;
+import org.jboss.portal.theme.render.ActionRenderContext;
import java.util.Collection;
import java.util.Collections;
@@ -54,8 +54,8 @@
StringBuffer markup = renderContext.getMarkupFragment();
renderTitle(renderContext, drc);
markup.append("<div class=\"portlet-mode-container\">");
- renderModeAndStateLinks(renderContext, drc, WindowResult.MODES_KEY);
- renderModeAndStateLinks(renderContext, drc, WindowResult.WINDOWSTATES_KEY);
+ renderModeAndStateLinks(renderContext, drc, ActionRenderContext.MODES_KEY);
+ renderModeAndStateLinks(renderContext, drc, ActionRenderContext.WINDOWSTATES_KEY);
markup.append("</div>");
}
@@ -85,7 +85,7 @@
for (Iterator i = modesOrStates.iterator(); i.hasNext();)
{
- WindowResult.Action action = (WindowResult.Action)i.next();
+ ActionRenderContext action = (ActionRenderContext)i.next();
if (action.isEnabled())
{
StringBuffer out = ctx.getMarkupFragment();
@@ -115,11 +115,11 @@
public int compare(Object o1, Object o2)
{
- WindowResult.Action action1 = (WindowResult.Action)o1;
- WindowResult.Action action2 = (WindowResult.Action)o2;
+ ActionRenderContext action1 = (ActionRenderContext)o1;
+ ActionRenderContext action2 = (ActionRenderContext)o2;
- Object origin1 = action1.getOrigin();
- Object origin2 = action2.getOrigin();
+ Object origin1 = action1.getFamily();
+ Object origin2 = action2.getFamily();
if (origin1.equals(origin2))
{
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivRegionRenderer.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -59,7 +59,7 @@
public void renderBody(RenderContext renderContext, RegionRenderContext rrc) throws RenderException
{
- for (Iterator i = rrc.getWindowRenderContexts().iterator(); i.hasNext();)
+ for (Iterator i = rrc.getWindows().iterator(); i.hasNext();)
{
WindowRenderContext wrc = (WindowRenderContext)i.next();
renderContext.render(wrc);
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/empty/EmptyRegionRenderer.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -63,7 +63,7 @@
Map orderedItems = new TreeMap();
//
- for (Iterator i = rrc.getWindowRenderContexts().iterator(); i.hasNext();)
+ for (Iterator i = rrc.getWindows().iterator(); i.hasNext();)
{
WindowRenderContext window = (WindowRenderContext)i.next();
orderedItems.put(new Integer(window.getOrder()), window);
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -113,7 +113,7 @@
* @param regionName the name of the region to get
* @return the region for the provided region name
*/
- public Region getRegion(String regionName)
+ public Region getRegion2(String regionName)
{
return (Region)regions.get(regionName);
}
@@ -273,12 +273,12 @@
}
- public Collection getRegionRenderContexts()
+ public Collection getRegions()
{
return regions.values();
}
- public RegionRenderContext getRegionRenderContext(String regionName)
+ public RegionRenderContext getRegion(String regionName)
{
return (RegionRenderContext)regions.get(regionName);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -123,7 +123,7 @@
*
* @return a sorted list of <code>org.jboss.portal.theme.page.WindowContext</code> items
*/
- public List getWindows()
+ public List getWindows2()
{
if (windows == null)
{
@@ -144,7 +144,7 @@
// RegionRenderContext implementation *******************************************************************************
- public Collection getWindowRenderContexts()
+ public Collection getWindows()
{
ArrayList wrcs = new ArrayList(windows.size());
for (Iterator i = windows.iterator(); i.hasNext();)
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowResult.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -24,6 +24,7 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.theme.render.ActionRenderContext;
import org.jboss.portal.portlet.Properties;
import java.util.Collection;
@@ -40,12 +41,6 @@
{
/** . */
- public static final String MODES_KEY = "mode";
-
- /** . */
- public static final String WINDOWSTATES_KEY = "windowstate";
-
- /** . */
private String title;
/** . */
@@ -162,10 +157,10 @@
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
*/
- public static class Action
+ public static class Action implements ActionRenderContext
{
/** The origin of the action. */
- private final Object origin;
+ private final String family;
/** The action url. */
private final String url;
@@ -173,28 +168,21 @@
/** Enabled or not. */
private final boolean enabled;
- public Action(Object origin, String url, boolean enabled)
+ public Action(String family, String url, boolean enabled)
{
- if (origin instanceof WindowState || origin instanceof Mode)
- {
- this.origin = origin;
- }
- else
- {
- throw new IllegalArgumentException("Action can only have a WindowState or Mode for origin. Was: " + origin);
- }
+ this.family = family;
this.url = url;
this.enabled = enabled;
}
public String getName()
{
- return origin.toString();
+ return family;
}
- public Object getOrigin()
+ public String getFamily()
{
- return origin;
+ return family;
}
public String getURL()
@@ -206,5 +194,10 @@
{
return enabled;
}
+
+ public String getProperty(String name)
+ {
+ return null;
+ }
}
}
Added: trunk/theme/src/main/org/jboss/portal/theme/render/ActionRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/ActionRenderContext.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/ActionRenderContext.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * 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.theme.render;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ActionRenderContext extends ObjectRenderContext
+{
+ /** . */
+ String MODES_KEY = "mode";
+ /** . */
+ String WINDOWSTATES_KEY = "windowstate";
+
+ String getName();
+
+ String getFamily();
+
+ String getURL();
+
+ boolean isEnabled();
+
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -30,7 +30,7 @@
*/
public interface PageRenderContext extends ObjectRenderContext
{
- Collection getRegionRenderContexts();
+ Collection getRegions();
- RegionRenderContext getRegionRenderContext(String regionName);
+ RegionRenderContext getRegion(String regionName);
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RegionRenderContext.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -35,7 +35,7 @@
String getId();
- Collection getWindowRenderContexts();
+ Collection getWindows();
Orientation getOrientation();
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -91,7 +91,7 @@
final String cssId = regionCssId == null ? regionName : regionCssId;
final Orientation orientation = this.regionOrientation == null ? Orientation.DEFAULT : this.regionOrientation;
- if (page.getRegionRenderContext(regionName) == null) // non-window display of content
+ if (page.getRegion(regionName) == null) // non-window display of content
{
// Create a dummy region obj, based on region name
RegionRenderContext rrc = new RegionRenderContext()
@@ -100,7 +100,7 @@
{
return regionName;
}
- public Collection getWindowRenderContexts()
+ public Collection getWindows()
{
return Collections.EMPTY_LIST;
}
@@ -148,7 +148,7 @@
return;
}
- final RegionRenderContext region = page.getRegionRenderContext(regionName);
+ final RegionRenderContext region = page.getRegion(regionName);
RegionRenderContext rrc = new RegionRenderContext()
{
public String getId()
@@ -156,9 +156,9 @@
return region.getId();
}
- public Collection getWindowRenderContexts()
+ public Collection getWindows()
{
- return region.getWindowRenderContexts();
+ return region.getWindows();
}
public Orientation getOrientation()
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.theme.tag.basic;
-import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.render.ActionRenderContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
@@ -63,7 +63,7 @@
{
if (iterator.hasNext())
{
- WindowResult.Action action = (WindowResult.Action)iterator.next();
+ ActionRenderContext action = (ActionRenderContext)iterator.next();
pageContext.setAttribute(ForEachActionInWindowTEI.IMPLICIT_NAME, action.getName());
pageContext.setAttribute(ForEachActionInWindowTEI.IMPLICIT_URL, action.getURL());
pageContext.setAttribute(ForEachActionInWindowTEI.IMPLICIT_ENABLED, Boolean.valueOf(action.isEnabled()));
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -26,7 +26,6 @@
import org.jboss.portal.theme.render.PageRenderContext;
import org.jboss.portal.theme.render.RegionRenderContext;
import org.jboss.portal.theme.render.WindowRenderContext;
-import org.jboss.portal.theme.page.PageResult;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
@@ -101,17 +100,17 @@
public int doStartTag() throws JspException
{
// Get the aggrehated page result from the request
- pageRenderContext = (PageResult)pageContext.getRequest().getAttribute(LayoutConstants.ATTR_PAGE);
+ pageRenderContext = (PageRenderContext)pageContext.getRequest().getAttribute(LayoutConstants.ATTR_PAGE);
// Aggregate the regions parameterized in the region attribute
List windows = new ArrayList(10);
for (StringTokenizer tokenizer = new StringTokenizer(this.region, ","); tokenizer.hasMoreTokens();)
{
String token = tokenizer.nextToken().trim();
- RegionRenderContext region = pageRenderContext.getRegionRenderContext(token);
+ RegionRenderContext region = pageRenderContext.getRegion(token);
if (region != null)
{
- for (Iterator i = region.getWindowRenderContexts().iterator(); i.hasNext();)
+ for (Iterator i = region.getWindows().iterator(); i.hasNext();)
{
WindowRenderContext window = (WindowRenderContext)i.next();
windows.add(window);
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -56,7 +56,7 @@
{
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
PageRenderContext page = (PageRenderContext)request.getAttribute(LayoutConstants.ATTR_PAGE);
- RegionRenderContext region = page.getRegionRenderContext(this.region);
+ RegionRenderContext region = page.getRegion(this.region);
if (region != null)
{
return Tag.EVAL_BODY_INCLUDE;
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java 2007-04-03 11:57:22 UTC (rev 6904)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionIsEmptyTag.java 2007-04-03 12:18:06 UTC (rev 6905)
@@ -56,8 +56,8 @@
{
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
PageResult page = (PageResult)request.getAttribute(LayoutConstants.ATTR_PAGE);
- Region region = page.getRegion(this.region);
- if (region != null && region.getWindows().iterator().hasNext())
+ Region region = page.getRegion2(this.region);
+ if (region != null && region.getWindows2().iterator().hasNext())
{
return Tag.SKIP_BODY;
}
17 years, 1 month
JBoss Portal SVN: r6904 - in trunk: theme/src/main/org/jboss/portal/test/theme/servlet and 5 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-03 07:57:22 -0400 (Tue, 03 Apr 2007)
New Revision: 6904
Added:
trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java
trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderer.java
Removed:
trunk/theme/src/main/org/jboss/portal/theme/page/render/
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java
trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java
trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java
Log:
more cleanup in layout, less dependencies on the XXXRenderContext implementations
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -47,7 +47,6 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.render.PageRenderContextImpl;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.PageRenderContext;
import org.jboss.portal.theme.render.WindowRenderContext;
@@ -329,7 +328,6 @@
// Call to the theme framework
PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
- PageRenderContext prc = new PageRenderContextImpl(res);
//
UpdatePageStateResponse updatePage = new UpdatePageStateResponse();
@@ -419,7 +417,7 @@
};
//
- RenderContext renderCtx = new RenderContext(layout, (MarkupInfo)invocation.getResponse().getContentInfo(), prc);
+ RenderContext renderCtx = new RenderContext(layout, (MarkupInfo)invocation.getResponse().getContentInfo(), res);
renderCtx.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, Boolean.TRUE);
renderCtx.render(wrc);
updatePage.addFragment(_window.getName(), renderCtx.getMarkupFragment().toString());
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -40,7 +40,6 @@
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.render.PageRenderContextImpl;
import org.jboss.portal.theme.render.PortalRenderSet;
import org.jboss.portal.theme.render.RenderContext;
@@ -130,7 +129,7 @@
}
// set the renderctx and req/res attr
- RenderContext renderCtx = new RenderContext(layout, markupInfo, new PageRenderContextImpl(pageResult));
+ RenderContext renderCtx = new RenderContext(layout, markupInfo, pageResult);
response.setContentType(renderCtx.getContentType().toString());
response.setCharacterEncoding(renderCtx.getCharset());
request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
Modified: trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -26,7 +26,7 @@
import org.jboss.portal.server.ServerRequest;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.portal.theme.page.render.PageRenderContextImpl;
+import org.jboss.portal.theme.render.PageRenderContext;
import org.jboss.portal.theme.page.PageResult;
import javax.servlet.ServletException;
@@ -101,8 +101,8 @@
* @param markupResult the result of the portlet render process
* @return a new render context
*/
- public RenderContext getRenderContext(MarkupInfo markupInfo, ServerRequest request, PageResult markupResult)
+ public RenderContext getRenderContext(MarkupInfo markupInfo, ServerRequest request, PageRenderContext markupResult)
{
- return new RenderContext(this, markupInfo, new PageRenderContextImpl(markupResult));
+ return new RenderContext(this, markupInfo, markupResult);
}
}
Copied: trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java (from rev 6899, trunk/theme/src/main/org/jboss/portal/theme/page/render/DecorationRenderContextImpl.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/DecorationRenderContextImpl.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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.theme.page;
+
+import org.jboss.portal.theme.render.DecorationRenderContext;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DecorationRenderContextImpl implements DecorationRenderContext
+{
+
+ final WindowRenderContextImpl wrc;
+
+ public DecorationRenderContextImpl(WindowRenderContextImpl wrc)
+ {
+ this.wrc = wrc;
+ }
+
+ public String getId()
+ {
+ return wrc.getId();
+ }
+
+ public String getTitle()
+ {
+ return wrc.result.getTitle();
+ }
+
+ public Collection getTriggerableActions(String familyName)
+ {
+ return wrc.result.getTriggerableActions(familyName);
+ }
+
+ public String getProperty(String name)
+ {
+ return wrc.getProperty(name);
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PageResult.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -23,12 +23,15 @@
package org.jboss.portal.theme.page;
import org.jboss.portal.theme.render.PortalRenderSet;
+import org.jboss.portal.theme.render.PageRenderContext;
+import org.jboss.portal.theme.render.RegionRenderContext;
import org.jboss.portal.theme.ThemeResult;
import org.jboss.portal.theme.PortalTheme;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.Collection;
/**
* Interface to represent the read only information of a rendered portal page. <p>The page result allows access to all
@@ -37,7 +40,7 @@
* @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
* @version $Revision$
*/
-public class PageResult
+public class PageResult implements PageRenderContext
{
/** . */
@@ -71,7 +74,7 @@
protected PortalTheme theme;
/** . */
- protected final Map regions;
+ final Map regions;
public PageResult(String pageName, Map pageProperties, Map portalProperties)
{
@@ -246,10 +249,37 @@
Region region = (Region)regions.get(windowContext.getRegionName());
if (region == null)
{
- region = new Region(windowContext.getRegionName());
+ region = new Region(this, windowContext.getRegionName());
}
region.addWindowContext(windowContext);
regions.put(region.getId(), region);
}
+
+ // PageRenderContext implementation *********************************************************************************
+
+ public String getProperty(String name)
+ {
+ String s = (String)getPageProperties().get(name);
+
+ //
+ if (s == null)
+ {
+ s = (String)getPortalProperties().get(name);
+ }
+
+ //
+ return s;
+ }
+
+
+ public Collection getRegionRenderContexts()
+ {
+ return regions.values();
+ }
+
+ public RegionRenderContext getRegionRenderContext(String regionName)
+ {
+ return (RegionRenderContext)regions.get(regionName);
+ }
}
Copied: trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java (from rev 6899, trunk/theme/src/main/org/jboss/portal/theme/page/render/PortletRenderContextImpl.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/PortletRenderContextImpl.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 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.theme.page;
+
+import org.jboss.portal.theme.render.PortletRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletRenderContextImpl implements PortletRenderContext
+{
+
+ final WindowRenderContextImpl wrc;
+
+ public PortletRenderContextImpl(WindowRenderContextImpl wrc)
+ {
+ this.wrc = wrc;
+ }
+
+ public String getMarkup()
+ {
+ return wrc.result.getContent();
+ }
+
+ public String getProperty(String name)
+ {
+ return wrc.getProperty(name);
+ }
+
+ public String getProperty(String name, int scope)
+ {
+ return getProperty(name);
+ }
+
+ public WindowRenderContext getWindow()
+ {
+ return wrc;
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/Region.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/Region.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -22,11 +22,17 @@
******************************************************************************/
package org.jboss.portal.theme.page;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.Orientation;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Collection;
+import java.util.Iterator;
/**
* A region on a page. <p>A region wraps one or more portlets to allow them to act as one unit inside the layout of a
@@ -35,13 +41,16 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public final class Region
+public final class Region implements RegionRenderContext
{
/** . */
private final String name;
/** . */
+ private final PageResult page;
+
+ /** . */
private boolean sorted;
/** . */
@@ -56,8 +65,9 @@
*
* @param name the name of the region to create
*/
- public Region(String name)
+ public Region(PageResult page, String name)
{
+ this.page = page;
this.name = name;
this.windows = new ArrayList();
this.sorted = false;
@@ -131,4 +141,29 @@
{
return "Region[name" + name + "]";
}
+
+ // RegionRenderContext implementation *******************************************************************************
+
+ public Collection getWindowRenderContexts()
+ {
+ ArrayList wrcs = new ArrayList(windows.size());
+ for (Iterator i = windows.iterator(); i.hasNext();)
+ {
+ WindowContext wc = (WindowContext)i.next();
+ WindowResult wr = page.getWindowResult(wc.getId());
+ WindowRenderContext wrc = new WindowRenderContextImpl(this, wc, wr);
+ wrcs.add(wrc);
+ }
+ return wrcs;
+ }
+
+ public Orientation getOrientation()
+ {
+ return null;
+ }
+
+ public String getCSSId()
+ {
+ return null;
+ }
}
Copied: trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java (from rev 6899, trunk/theme/src/main/org/jboss/portal/theme/page/render/WindowRenderContextImpl.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowRenderContextImpl.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * 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.theme.page;
+
+import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.render.DecorationRenderContext;
+import org.jboss.portal.theme.render.PortletRenderContext;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WindowRenderContextImpl implements WindowRenderContext
+{
+
+ final Region region;
+ final WindowContext context;
+ final WindowResult result;
+ private final DecorationRenderContextImpl drc = new DecorationRenderContextImpl(this);
+ private final PortletRenderContextImpl prc = new PortletRenderContextImpl(this);
+
+ public WindowRenderContextImpl(Region region, WindowContext context, WindowResult result)
+ {
+ this.region = region;
+ this.context = context;
+ this.result = result;
+ }
+
+ public String getId()
+ {
+ return context.getId().toString();
+ }
+
+ public int getOrder()
+ {
+ return context.getOrder();
+ }
+
+ public WindowState getWindowState()
+ {
+ return result.getWindowState();
+ }
+
+ public Mode getMode()
+ {
+ return result.getMode();
+ }
+
+ public DecorationRenderContext getDecoration()
+ {
+ return drc;
+ }
+
+ public PortletRenderContext getPortlet()
+ {
+ return prc;
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)result.getWindowProperties().get(name);
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderContext.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -22,10 +22,15 @@
******************************************************************************/
package org.jboss.portal.theme.render;
+import java.util.Collection;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
public interface PageRenderContext extends ObjectRenderContext
{
+ Collection getRegionRenderContexts();
+
+ RegionRenderContext getRegionRenderContext(String regionName);
}
Added: trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderer.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/PageRenderer.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * 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.theme.render;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PageRenderer extends ObjectRenderer
+{
+ void render(RenderContext renderContext, PageRenderContext prc) throws RenderException;
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/PortletTagHandler.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -24,15 +24,8 @@
import org.jboss.logging.Logger;
import org.jboss.portal.theme.LayoutConstants;
-import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.page.Region;
-import org.jboss.portal.theme.render.RenderContext;
-import org.jboss.portal.theme.render.RenderException;
-import org.jboss.portal.theme.page.render.PageRenderContextImpl;
-import org.jboss.portal.theme.render.RegionRenderContext;
-import org.jboss.portal.theme.page.render.RegionRenderContextImpl;
-import org.jboss.portal.theme.render.WindowRenderContext;
+import org.jboss.portal.theme.render.PageRenderContext;
+import org.jboss.portal.common.NotYetImplemented;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@@ -40,8 +33,6 @@
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
/**
* Tag handler for the portlet tag. <p>This tag adds the created markup of a Portlet to a page. The portlet tag utilizes
@@ -91,7 +82,7 @@
PageContext app = (PageContext)getJspContext();
HttpServletRequest request = (HttpServletRequest)app.getRequest();
- PageResult page = (PageResult)request.getAttribute(LayoutConstants.ATTR_PAGE);
+ PageRenderContext page = (PageRenderContext)request.getAttribute(LayoutConstants.ATTR_PAGE);
if (page == null)
{
out.write("<p bgcolor='red'>No page to render!</p>");
@@ -101,62 +92,64 @@
return;
}
- String windowID = null;
- boolean wIdFound = false;
- // we have the windowName (which is the window name), but we need the
- // window id
- Map portletContexts = page.getWindowContextMap();
- for (Iterator i = portletContexts.keySet().iterator(); i.hasNext();) {
- windowID = (String) i.next();
- WindowContext portletContext = (WindowContext) portletContexts
- .get(windowID);
- if (windowName.equals(portletContext.getWindowName())) {
- wIdFound = true;
- if (log.isDebugEnabled()) {
- log.debug("found the portlet to render: " + windowName);
- }
- break;
- }
- }
+// String windowID = null;
+// boolean wIdFound = false;
+// // we have the windowName (which is the window name), but we need the
+// // window id
+// Map portletContexts = page.getWindowContextMap();
+// for (Iterator i = portletContexts.keySet().iterator(); i.hasNext();) {
+// windowID = (String) i.next();
+// WindowContext portletContext = (WindowContext) portletContexts
+// .get(windowID);
+// if (windowName.equals(portletContext.getWindowName())) {
+// wIdFound = true;
+// if (log.isDebugEnabled()) {
+// log.debug("found the portlet to render: " + windowName);
+// }
+// break;
+// }
+// }
+//
+// if (!wIdFound) {
+// log
+// .warn("can't find the window id of the window name on this page. Page=["
+// + page.getPageName()
+// + "] and Window=["
+// + windowName
+// + "]. This window won't be shown in page.");
+// return;
+// }
+// if (page.getWindowContext(windowID) == null) {
+// log.warn("no such window on this page. Page [" + page.getPageName()
+// + "] Window name [" + windowName + "]" + "] Window Id ["
+// + windowID + "]");
+// return;
+// }
+//
+// WindowContext windowContext = page.getWindowContext(windowID);
+// RenderContext renderContext = (RenderContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
+//
+// PageRenderContextImpl prc = new PageRenderContextImpl(page);
+// String regionName = windowContext.getRegionName();
+// Region region = page.getRegion(regionName);
+// RegionRenderContext rrc = new RegionRenderContextImpl(prc, region, null, null);
+// for (Iterator i = rrc.getWindowRenderContexts().iterator();i.hasNext();)
+// {
+// WindowRenderContext wrc = (WindowRenderContext)i.next();
+// if (wrc.getId().equals(windowContext.getId()))
+// {
+// try {
+// renderContext.render(wrc);
+// out.write(renderContext.getMarkupFragment().toString());
+// out.flush();
+// } catch (RenderException e) {
+// throw new JspException(e);
+// }
+// break;
+// }
+// }
- if (!wIdFound) {
- log
- .warn("can't find the window id of the window name on this page. Page=["
- + page.getPageName()
- + "] and Window=["
- + windowName
- + "]. This window won't be shown in page.");
- return;
- }
- if (page.getWindowContext(windowID) == null) {
- log.warn("no such window on this page. Page [" + page.getPageName()
- + "] Window name [" + windowName + "]" + "] Window Id ["
- + windowID + "]");
- return;
- }
-
- WindowContext windowContext = page.getWindowContext(windowID);
- RenderContext renderContext = (RenderContext)request.getAttribute(LayoutConstants.ATTR_RENDERCONTEXT);
-
- PageRenderContextImpl prc = new PageRenderContextImpl(page);
- String regionName = windowContext.getRegionName();
- Region region = page.getRegion(regionName);
- RegionRenderContext rrc = new RegionRenderContextImpl(prc, region, null, null);
- for (Iterator i = rrc.getWindowRenderContexts().iterator();i.hasNext();)
- {
- WindowRenderContext wrc = (WindowRenderContext)i.next();
- if (wrc.getId().equals(windowContext.getId()))
- {
- try {
- renderContext.render(wrc);
- out.write(renderContext.getMarkupFragment().toString());
- out.flush();
- } catch (RenderException e) {
- throw new JspException(e);
- }
- break;
- }
- }
+ throw new NotYetImplemented();
}
public String getWindowName()
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/RegionTagHandler.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -25,13 +25,9 @@
import org.jboss.logging.Logger;
import org.jboss.portal.theme.LayoutConstants;
import org.jboss.portal.theme.Orientation;
-import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.Region;
-import org.jboss.portal.theme.page.render.PageRenderContextImpl;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.render.RegionRenderContext;
-import org.jboss.portal.theme.page.render.RegionRenderContextImpl;
import org.jboss.portal.theme.render.PageRenderContext;
import javax.servlet.http.HttpServletRequest;
@@ -81,7 +77,7 @@
PageContext app = (PageContext)getJspContext();
HttpServletRequest request = (HttpServletRequest)app.getRequest();
- PageResult page = (PageResult)request.getAttribute(LayoutConstants.ATTR_PAGE);
+ PageRenderContext page = (PageRenderContext)request.getAttribute(LayoutConstants.ATTR_PAGE);
JspWriter out = this.getJspContext().getOut();
if (page == null)
{
@@ -95,7 +91,7 @@
final String cssId = regionCssId == null ? regionName : regionCssId;
final Orientation orientation = this.regionOrientation == null ? Orientation.DEFAULT : this.regionOrientation;
- if (page.getRegion(regionName) == null) // non-window display of content
+ if (page.getRegionRenderContext(regionName) == null) // non-window display of content
{
// Create a dummy region obj, based on region name
RegionRenderContext rrc = new RegionRenderContext()
@@ -152,9 +148,34 @@
return;
}
- Region region = page.getRegion(regionName);
- PageRenderContextImpl prc = new PageRenderContextImpl(page);
- RegionRenderContext rrc = new RegionRenderContextImpl(prc, region, cssId, orientation);
+ final RegionRenderContext region = page.getRegionRenderContext(regionName);
+ RegionRenderContext rrc = new RegionRenderContext()
+ {
+ public String getId()
+ {
+ return region.getId();
+ }
+
+ public Collection getWindowRenderContexts()
+ {
+ return region.getWindowRenderContexts();
+ }
+
+ public Orientation getOrientation()
+ {
+ return orientation;
+ }
+
+ public String getCSSId()
+ {
+ return cssId;
+ }
+
+ public String getProperty(String name)
+ {
+ return region.getProperty(name);
+ }
+ };
try
{
renderContext.render(rrc);
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachActionInWindowTag.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -79,8 +79,7 @@
{
//
ForEachWindowInRegionTag other = (ForEachWindowInRegionTag)findAncestorWithClass(this, ForEachWindowInRegionTag.class);
- WindowResult windowResult = other.getWindowResult();
- Collection actions = windowResult.getTriggerableActions(family);
+ Collection actions = other.getWindowRenderContext().getDecoration().getTriggerableActions(family);
if (actions != null)
{
iterator = actions.iterator();
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/basic/ForEachWindowInRegionTag.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -23,10 +23,10 @@
package org.jboss.portal.theme.tag.basic;
import org.jboss.portal.theme.LayoutConstants;
+import org.jboss.portal.theme.render.PageRenderContext;
+import org.jboss.portal.theme.render.RegionRenderContext;
+import org.jboss.portal.theme.render.WindowRenderContext;
import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.Region;
-import org.jboss.portal.theme.page.WindowContext;
-import org.jboss.portal.theme.page.WindowResult;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
@@ -54,10 +54,10 @@
private Iterator iterator;
/** . */
- private PageResult pageResult;
+ private PageRenderContext pageRenderContext;
/** . */
- private WindowResult windowResult;
+ private WindowRenderContext windowRenderContext;
public String getRegion()
{
@@ -69,9 +69,9 @@
this.region = region;
}
- public WindowResult getWindowResult()
+ public WindowRenderContext getWindowRenderContext()
{
- return windowResult;
+ return windowRenderContext;
}
// BodyTag implementation *******************************************************************************************
@@ -81,16 +81,13 @@
if (iterator.hasNext())
{
// Get the next window context
- WindowContext item = (WindowContext)iterator.next();
+ windowRenderContext = (WindowRenderContext)iterator.next();
- // Get window result
- windowResult = pageResult.getWindowResult(item.getId());
-
// Set the implicit content
- pageContext.setAttribute(ForEachWindowInRegionTEI.IMPLICIT_CONTENT, windowResult.getContent());
+ pageContext.setAttribute(ForEachWindowInRegionTEI.IMPLICIT_CONTENT, this.windowRenderContext.getPortlet().getMarkup());
// Set the implicit title
- pageContext.setAttribute(ForEachWindowInRegionTEI.IMPLICIT_TITLE, String.valueOf(windowResult.getTitle()));
+ pageContext.setAttribute(ForEachWindowInRegionTEI.IMPLICIT_TITLE, String.valueOf(windowRenderContext.getDecoration().getTitle()));
//
return true;
@@ -104,19 +101,19 @@
public int doStartTag() throws JspException
{
// Get the aggrehated page result from the request
- pageResult = (PageResult)pageContext.getRequest().getAttribute(LayoutConstants.ATTR_PAGE);
+ pageRenderContext = (PageResult)pageContext.getRequest().getAttribute(LayoutConstants.ATTR_PAGE);
// Aggregate the regions parameterized in the region attribute
List windows = new ArrayList(10);
for (StringTokenizer tokenizer = new StringTokenizer(this.region, ","); tokenizer.hasMoreTokens();)
{
String token = tokenizer.nextToken().trim();
- Region region = pageResult.getRegion(token);
+ RegionRenderContext region = pageRenderContext.getRegionRenderContext(token);
if (region != null)
{
- for (Iterator i = region.getWindows().iterator(); i.hasNext();)
+ for (Iterator i = region.getWindowRenderContexts().iterator(); i.hasNext();)
{
- WindowContext window = (WindowContext)i.next();
+ WindowRenderContext window = (WindowRenderContext)i.next();
windows.add(window);
}
}
@@ -153,8 +150,8 @@
public int doEndTag() throws JspException
{
iterator = null;
- pageResult = null;
- windowResult = null;
+ pageRenderContext = null;
+ windowRenderContext = null;
return Tag.EVAL_PAGE;
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java 2007-04-02 23:11:59 UTC (rev 6903)
+++ trunk/theme/src/main/org/jboss/portal/theme/tag/basic/IfRegionExistsTag.java 2007-04-03 11:57:22 UTC (rev 6904)
@@ -23,8 +23,8 @@
package org.jboss.portal.theme.tag.basic;
import org.jboss.portal.theme.LayoutConstants;
-import org.jboss.portal.theme.page.PageResult;
-import org.jboss.portal.theme.page.Region;
+import org.jboss.portal.theme.render.PageRenderContext;
+import org.jboss.portal.theme.render.RegionRenderContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@@ -55,8 +55,8 @@
public int doStartTag() throws JspException
{
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
- PageResult page = (PageResult)request.getAttribute(LayoutConstants.ATTR_PAGE);
- Region region = page.getRegion(this.region);
+ PageRenderContext page = (PageRenderContext)request.getAttribute(LayoutConstants.ATTR_PAGE);
+ RegionRenderContext region = page.getRegionRenderContext(this.region);
if (region != null)
{
return Tag.EVAL_BODY_INCLUDE;
17 years, 1 month
JBoss Portal SVN: r6903 - in trunk/portlet/src: main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher and 4 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-02 19:11:59 -0400 (Mon, 02 Apr 2007)
New Revision: 6903
Added:
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatchingFilter.java
trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/dispatchedFromFilter.jsp
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java
trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml
trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml
trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml
Log:
- improving implementation request dispatching from portlet to servlet
- added more test cases for the request dispatching from portlet to servlet
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2007-04-02 21:41:23 UTC (rev 6902)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/DispatchedHttpServletRequest.java 2007-04-02 23:11:59 UTC (rev 6903)
@@ -37,12 +37,9 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
-import java.util.Collections;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.Iterator;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -60,7 +57,6 @@
private RenderRequestImpl rreq;
private HttpServletRequest dreq;
- private final Map attrs;
private final Map parameters;
public DispatchedHttpServletRequest(
@@ -77,8 +73,6 @@
//
if (path != null)
{
- String servletPath;
- String pathInfo;
String queryString;
int endOfServletPath = path.indexOf('/', 1);
@@ -87,44 +81,27 @@
endOfServletPath = path.indexOf('?', 1);
if (endOfServletPath == -1)
{
- servletPath = path;
- pathInfo = "";
queryString = "";
}
else
{
- servletPath = path.substring(0, endOfServletPath);
- pathInfo = "";
queryString = path.substring(endOfServletPath + 1);
}
}
else
{
- servletPath = path.substring(0, endOfServletPath);
int endOfPathInfo = path.indexOf('?', endOfServletPath + 1);
if (endOfPathInfo == -1)
{
- pathInfo = path.substring(endOfServletPath);
queryString = "";
}
else
{
- pathInfo = path.substring(endOfServletPath, endOfPathInfo);
queryString = path.substring(endOfPathInfo + 1);
}
}
- String requestURI = rreq.getContextPath() + servletPath + pathInfo;
//
- Map attrs = new HashMap(5);
- attrs.put(CONTEXT_PATH, rreq.getContextPath());
- attrs.put(SERVLET_PATH, servletPath);
- attrs.put(PATH_INFO, pathInfo);
- attrs.put(QUERY_STRING, queryString);
- attrs.put(REQUEST_URI, requestURI);
- this.attrs = Collections.unmodifiableMap(attrs);
-
- //
if (queryString.length() > 0)
{
this.parameters = new PortletParameters(rreq.getParameterMap());
@@ -137,7 +114,6 @@
}
else
{
- this.attrs = Collections.EMPTY_MAP;
this.parameters = rreq.getParameterMap();
}
}
@@ -173,22 +149,22 @@
public String getPathInfo()
{
- return (String)attrs.get(PATH_INFO);
+ return (String)getAttribute(PATH_INFO);
}
public String getQueryString()
{
- return (String)attrs.get(QUERY_STRING);
+ return (String)getAttribute(QUERY_STRING);
}
public String getServletPath()
{
- return (String)attrs.get(SERVLET_PATH);
+ return (String)getAttribute(SERVLET_PATH);
}
public String getRequestURI()
{
- return (String)attrs.get(REQUEST_URI);
+ return (String)getAttribute(REQUEST_URI);
}
public String getPathTranslated()
@@ -216,11 +192,11 @@
public Object getAttribute(String s)
{
// First try the special values
- Object value = attrs.get(s);
- if (value != null)
- {
- return value;
- }
+// Object value = attrs.get(s);
+// if (value != null)
+// {
+// return value;
+// }
// Otherwise try the render request modified attributes
return rreq.getAttributes().getAttribute(s, (HttpServletRequest)getRequest());
@@ -228,49 +204,49 @@
public Enumeration getAttributeNames()
{
- final Iterator i = rreq.getAttributes().getAttributeNames((HttpServletRequest)getRequest());
- return new Enumeration()
- {
- // The next element
- Object next;
-
- {
- next();
- }
-
- public boolean hasMoreElements()
- {
- return next != null;
- }
-
- public Object nextElement()
- {
- Object next = this.next;
- next();
- return next;
- }
-
- private void next()
- {
- next = null;
- while (true)
- {
- if (i.hasNext())
- {
- Object next = i.next();
- if (attrs != null && !attrs.containsKey(next))
- {
- this.next = next;
- break;
- }
- }
- else
- {
- break;
- }
- }
- }
- };
+ return Tools.toEnumeration(rreq.getAttributes().getAttributeNames((HttpServletRequest)getRequest()));
+// return new Enumeration()
+// {
+// // The next element
+// Object next;
+//
+// {
+// next();
+// }
+//
+// public boolean hasMoreElements()
+// {
+// return next != null;
+// }
+//
+// public Object nextElement()
+// {
+// Object next = this.next;
+// next();
+// return next;
+// }
+//
+// private void next()
+// {
+// next = null;
+// while (true)
+// {
+// if (i.hasNext())
+// {
+// Object next = i.next();
+// if (attrs != null && !attrs.containsKey(next))
+// {
+// this.next = next;
+// break;
+// }
+// }
+// else
+// {
+// break;
+// }
+// }
+// }
+// };
}
public void setAttribute(String s, Object o)
@@ -305,7 +281,7 @@
public String getContextPath()
{
- return (String)attrs.get(CONTEXT_PATH);
+ return (String)getAttribute(CONTEXT_PATH);
}
public String getRemoteUser()
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java 2007-04-02 21:41:23 UTC (rev 6902)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatcherSequenceBuilder.java 2007-04-02 23:11:59 UTC (rev 6903)
@@ -37,6 +37,7 @@
import org.jboss.portal.test.portlet.framework.UTP1;
import org.jboss.portal.test.portlet.framework.UTS1;
import org.jboss.portal.test.portlet.framework.UTP2;
+import org.jboss.portal.test.portlet.framework.UTP3;
import javax.portlet.Portlet;
import javax.portlet.PortletException;
@@ -140,10 +141,10 @@
});
}
- public void createBlah(PortletTestDriver registry)
+ public void createFilters(PortletTestDriver registry)
{
PortletTest seq = new PortletTest();
- registry.addSequence("Blah", seq);
+ registry.addSequence("Filters", seq);
seq.addAction(0, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
@@ -166,4 +167,32 @@
}
});
}
+
+ public void createDispatchingFilter(PortletTestDriver registry)
+ {
+ PortletTest seq = new PortletTest();
+ registry.addSequence("DispatchingFilter", seq);
+ seq.addAction(0, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+
+ // Need to set content type as we will include a JSP that will produce output
+ response.setContentType("text/html");
+
+ //
+ PortletRequestDispatcher prd = request.getPortletSession().getPortletContext().getNamedDispatcher("TargetForIncludeNamedDispatchingFilter");
+ assertNotNull(prd);
+ prd.include(request, response);
+
+ //
+ prd = request.getPortletSession().getPortletContext().getRequestDispatcher("/TargetForIncludeURLPatternDispatchingFilter");
+ assertNotNull(prd);
+ prd.include(request, response);
+
+ //
+ return new EndTestResponse();
+ }
+ });
+ }
}
Added: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatchingFilter.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatchingFilter.java (rev 0)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/dispatcher/DispatchingFilter.java 2007-04-02 23:11:59 UTC (rev 6903)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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.test.portlet.jsr168.ext.dispatcher;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.FilterChain;
+import javax.servlet.RequestDispatcher;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DispatchingFilter implements Filter
+{
+
+ private FilterConfig cfg;
+
+ public void init(FilterConfig cfg) throws ServletException
+ {
+ this.cfg = cfg;
+ }
+
+ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException
+ {
+
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+ System.out.println("In the CHAIN " + cfg.getFilterName());
+
+ RequestDispatcher rd = cfg.getServletContext().getRequestDispatcher("/dispatchedFromFilter.jsp");
+ rd.include(req, resp);
+
+ }
+
+ public void destroy()
+ {
+ this.cfg = null;
+ }
+}
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java 2007-04-02 21:41:23 UTC (rev 6902)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/dispatcher/DispatcherSequenceBuilder.java 2007-04-02 23:11:59 UTC (rev 6903)
@@ -274,18 +274,18 @@
{
protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
{
- PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA");
+ PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getRequestDispatcher("/universalServletA/pathinfo?foo=bar");
assertNotNull(dispatcher);
//assert that servlet HAS access to specific request attributes
try
{
dispatcher.include(request, response);
- assertNotNull(UTP1.local1.get());
- assertNotNull(UTP1.local2.get());
- assertNotNull(UTP1.local3.get());
- // assertNotNull(IncludedRequestParametersPortlet.local4.get());
- // assertNotNull(IncludedRequestParametersPortlet.local5.get());
+ assertEquals("/test-jsr168-dispatcher/universalServletA/pathinfo", UTP1.local1.get());
+ assertEquals("/test-jsr168-dispatcher", UTP1.local2.get());
+ assertEquals("/universalServletA", UTP1.local3.get());
+ assertEquals("/pathinfo", UTP1.local4.get());
+ assertEquals("foo=bar", UTP1.local5.get());
}
finally
{
@@ -296,25 +296,12 @@
UTP1.local5.set(null);
}
- //assert that keys are present in request properties
- Enumeration names = request.getPropertyNames();
- List namesList = new LinkedList();
- while (names.hasMoreElements())
- {
- namesList.add(names.nextElement());
- }
- /*assertTrue(namesList.contains("javax.servlet.include.request_uri"));
- assertTrue(namesList.contains("javax.servlet.include.context_path"));
- assertTrue(namesList.contains("javax.servlet.include.servlet_path"));
- assertTrue(namesList.contains("javax.servlet.include.path_info"));
- assertTrue(namesList.contains("javax.servlet.include.query_string"));*/
-
-
+ //
dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().getNamedDispatcher("UniversalServletA");
assertNotNull(dispatcher);
- //assert that servlet has NO access to specific request attributes
- //it shouldn't access that attributes because getNamedDispatcher was used
+ // Assert that servlet has NO access to specific request attributes
+ // it shouldn't access that attributes because getNamedDispatcher was used
try
{
dispatcher.include(request, response);
@@ -333,18 +320,6 @@
UTP1.local5.set(null);
}
- //assert that keys are not present in request properties
- names = request.getPropertyNames();
- namesList = new LinkedList();
- while (names.hasMoreElements())
- {
- namesList.add(names.nextElement());
- }
- assertTrue(!namesList.contains("javax.servlet.include.request_uri"));
- assertTrue(!namesList.contains("javax.servlet.include.context_path"));
- assertTrue(!namesList.contains("javax.servlet.include.servlet_path"));
- assertTrue(!namesList.contains("javax.servlet.include.path_info"));
- assertTrue(!namesList.contains("javax.servlet.include.query_string"));
return new EndTestResponse();
}
});
@@ -480,7 +455,7 @@
assertNull(request.getRequestURL());
//SPEC:130
- assertEquals("", request.getPathInfo());
+ assertEquals(null, request.getPathInfo());
//TODO:I'm not sure what this should return - but it's not implemented now so it fails
//assertEquals("",request.getPathTranslated());
assertEquals("key1=k1value1&key2=k2value1", request.getQueryString());
Modified: trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml 2007-04-02 21:41:23 UTC (rev 6902)
+++ trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/portlet.xml 2007-04-02 23:11:59 UTC (rev 6903)
@@ -50,4 +50,15 @@
</portlet-info>
</portlet>
+ <portlet>
+ <portlet-name>TestUniversalPortletC</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP3</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
</portlet-app>
Modified: trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml 2007-04-02 21:41:23 UTC (rev 6902)
+++ trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/WEB-INF/web.xml 2007-04-02 23:11:59 UTC (rev 6903)
@@ -82,6 +82,24 @@
</init-param>
</filter>
+ <filter>
+ <filter-name>IncludeNamedJSPDispatchingFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.DispatchingFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_NAMED_FILTER</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
+ <filter-name>IncludeURLPatternJSPDispatchingFilter</filter-name>
+ <filter-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.DispatchingFilter</filter-class>
+ <init-param>
+ <param-name>id</param-name>
+ <param-value>INCLUDE_URL_PATTERN_FILTER</param-value>
+ </init-param>
+ </filter>
+
<filter-mapping>
<filter-name>IncludeURLPatternFilter</filter-name>
<url-pattern>/noop</url-pattern>
@@ -118,6 +136,18 @@
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
+ <filter-mapping>
+ <filter-name>IncludeNamedJSPDispatchingFilter</filter-name>
+ <servlet-name>TargetForIncludeNamedDispatchingFilter</servlet-name>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>IncludeURLPatternJSPDispatchingFilter</filter-name>
+ <url-pattern>/TargetForIncludeURLPatternDispatchingFilter</url-pattern>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
<listener>
<listener-class>org.jboss.portal.test.portlet.jsr168.ext.dispatcher.DispatcherSequenceBuilder</listener-class>
</listener>
@@ -132,6 +162,16 @@
<servlet-class>org.jboss.portal.test.portlet.framework.NoopServlet</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>TargetForIncludeNamedDispatchingFilter</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.framework.NoopServlet</servlet-class>
+ </servlet>
+
+ <servlet>
+ <servlet-name>TargetForIncludeURLPatternDispatchingFilter</servlet-name>
+ <servlet-class>org.jboss.portal.test.portlet.framework.NoopServlet</servlet-class>
+ </servlet>
+
<servlet-mapping>
<servlet-name>UniversalServletA</servlet-name>
<url-pattern>/universalServletA</url-pattern>
@@ -142,4 +182,9 @@
<url-pattern>/noop</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>TargetForIncludeURLPatternDispatchingFilter</servlet-name>
+ <url-pattern>/TargetForIncludeURLPatternDispatchingFilter</url-pattern>
+ </servlet-mapping>
+
</web-app>
Added: trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/dispatchedFromFilter.jsp
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/dispatchedFromFilter.jsp (rev 0)
+++ trunk/portlet/src/resources/test/jsr168/ext/dispatcher-war/dispatchedFromFilter.jsp 2007-04-02 23:11:59 UTC (rev 6903)
@@ -0,0 +1,8 @@
+<%@ page language="java" %>
+
+<%
+ System.out.println("HELLO FROM JSP");
+ System.out.println("HELLO FROM JSP");
+ System.out.println("HELLO FROM JSP");
+ System.out.println("HELLO FROM JSP");
+%>
\ No newline at end of file
Modified: trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml 2007-04-02 21:41:23 UTC (rev 6902)
+++ trunk/portlet/src/resources/test/jsr168/tck/dispatcher-war/WEB-INF/web.xml 2007-04-02 23:11:59 UTC (rev 6903)
@@ -36,21 +36,9 @@
<servlet-class>org.jboss.portal.test.portlet.framework.UTS1</servlet-class>
</servlet>
- <servlet>
- <servlet-name>UniversalServletB</servlet-name>
- <servlet-class>org.jboss.portal.test.portlet.framework.UTS2</servlet-class>
- </servlet>
-
<servlet-mapping>
<servlet-name>UniversalServletA</servlet-name>
- <url-pattern>/universalServletA</url-pattern>
+ <url-pattern>/universalServletA/*</url-pattern>
</servlet-mapping>
- <servlet-mapping>
- <servlet-name>UniversalServletB</servlet-name>
- <url-pattern>/universalServletB</url-pattern>
- </servlet-mapping>
-
-
-
</web-app>
17 years, 1 month
JBoss Portal SVN: r6902 - in trunk/core/src/main/org/jboss/portal/core/model/portal: ns and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-02 17:41:23 -0400 (Mon, 02 Apr 2007)
New Revision: 6902
Added:
trunk/core/src/main/org/jboss/portal/core/model/portal/ns/
trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java
trunk/core/src/main/org/jboss/portal/core/model/portal/ns/WindowNavigationalState.java
Log:
added missing files
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/ns/PortalObjectNavigationalStateContext.java 2007-04-02 21:41:23 UTC (rev 6902)
@@ -0,0 +1,320 @@
+/******************************************************************************
+ * 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.core.model.portal.ns;
+
+import org.jboss.portal.core.ns.NavigationalStateContext;
+import org.jboss.portal.core.ns.NavigationalStateKey;
+import org.jboss.portal.core.ns.NavigationalStateObjectChange;
+import org.jboss.portal.core.ns.NavigationalStateObjectCreated;
+import org.jboss.portal.core.ns.NavigationalStateObjectUpdated;
+import org.jboss.portal.core.ns.NavigationalStateObjectDestroyed;
+import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.StateString;
+
+import java.util.Set;
+import java.util.LinkedHashMap;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortalObjectNavigationalStateContext implements NavigationalStateContext
+{
+
+ /** . */
+ private static final String VIEW_ID_KEY = "view_id";
+
+ /** . */
+ private static final int MODE_TYPE = 0;
+
+ /** . */
+ private static final int WINDOW_STATE_TYPE = 1;
+
+ /** . */
+ private static final int STATE_STRING_TYPE = 2;
+
+ /** . */
+ private static final int WINDOW_TYPE = 3;
+
+ /** . */
+ private static final int UNKNOWN_TYPE = 4;
+
+ /** Where we delegate the storage. */
+ private AttributeResolver store;
+
+ /** The changes. */
+ private LinkedHashMap changes;
+
+ public PortalObjectNavigationalStateContext(AttributeResolver store)
+ {
+ this.store = store;
+ }
+
+ public Set getKeys()
+ {
+ throw new UnsupportedOperationException("todo");
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ NavigationalStateKey nsKey = (NavigationalStateKey)attrKey;
+
+ // Browse changes first
+ if (changes != null)
+ {
+ NavigationalStateObjectChange change = (NavigationalStateObjectChange)changes.get(nsKey);
+ if (change instanceof NavigationalStateObjectCreated)
+ {
+ NavigationalStateObjectCreated created = (NavigationalStateObjectCreated)change;
+ return created.getValue();
+ }
+ else if (change instanceof NavigationalStateObjectUpdated)
+ {
+ NavigationalStateObjectUpdated updated = (NavigationalStateObjectUpdated)change;
+ return updated.getNewValue();
+ }
+ else if (change instanceof NavigationalStateObjectDestroyed)
+ {
+ return null;
+ }
+ }
+
+ //
+ return store.getAttribute(nsKey);
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ NavigationalStateKey wantedKey = (NavigationalStateKey)attrKey;
+ Class typeClass = wantedKey.getType();
+
+ // Get the effective lookup key
+ int typeValue = UNKNOWN_TYPE;
+ if (typeClass == WindowState.class)
+ {
+ typeValue = WINDOW_STATE_TYPE;
+ }
+ else if (typeClass == Mode.class)
+ {
+ typeValue = MODE_TYPE;
+ }
+ else if (StateString.class.isAssignableFrom(typeClass))
+ {
+ typeValue = STATE_STRING_TYPE;
+ }
+ else if (typeClass == WindowNavigationalState.class)
+ {
+ typeValue = WINDOW_TYPE;
+ }
+
+ if (typeValue == UNKNOWN_TYPE)
+ {
+ throw new IllegalArgumentException("Cannot handle the type " + typeClass.getName());
+ }
+
+ // Compute the effective key
+ NavigationalStateKey effectiveKey = typeValue == WINDOW_TYPE ? wantedKey : new NavigationalStateKey(WindowNavigationalState.class, wantedKey.getId());
+
+ //
+ WindowNavigationalState oldNS = null;
+
+ // Look first the old ns in the changes
+ if (changes != null)
+ {
+ NavigationalStateObjectChange change = (NavigationalStateObjectChange)changes.get(effectiveKey);
+ if (change != null)
+ {
+ // Discard any change done so far
+ changes.remove(effectiveKey);
+
+ //
+ if (change instanceof NavigationalStateObjectCreated)
+ {
+ NavigationalStateObjectCreated created = (NavigationalStateObjectCreated)change;
+ oldNS = (WindowNavigationalState)created.getValue();
+ }
+ else if (change instanceof NavigationalStateObjectUpdated)
+ {
+ NavigationalStateObjectUpdated updated = (NavigationalStateObjectUpdated)change;
+ oldNS = (WindowNavigationalState)updated.getNewValue();
+ }
+
+ //
+ }
+ }
+
+ // If we don't have the old ns then we try the store
+ if (oldNS == null)
+ {
+ oldNS = (WindowNavigationalState)store.getAttribute(effectiveKey);
+ }
+
+ //
+ NavigationalStateObjectChange change;
+ if (attrValue == null)
+ {
+ if (oldNS != null)
+ {
+ change = new NavigationalStateObjectDestroyed(effectiveKey, oldNS);
+ }
+ else
+ {
+ // Remove a non existing value, we do nothing
+ change = null;
+ }
+ }
+ else
+ {
+ WindowNavigationalState newNS;
+ if (typeValue == WINDOW_TYPE)
+ {
+ newNS = (WindowNavigationalState)attrValue;
+ }
+ else
+ {
+ WindowState windowState = WindowState.NORMAL;
+ Mode mode = Mode.VIEW;
+ StateString stateString = null;
+
+ //
+ if (oldNS != null)
+ {
+ windowState = oldNS.getWindowState();
+ mode = oldNS.getMode();
+ stateString = oldNS.getNavigationalState();
+ }
+
+ //
+ switch (typeValue)
+ {
+ case WINDOW_STATE_TYPE:
+ windowState = (WindowState)attrValue;
+ break;
+ case MODE_TYPE:
+ mode = (Mode)attrValue;
+ break;
+ case STATE_STRING_TYPE:
+ stateString = (StateString)attrValue;
+ break;
+ }
+
+ //
+ newNS = new WindowNavigationalState(windowState, mode, stateString);
+ }
+
+ //
+ if (oldNS != null)
+ {
+ change = new NavigationalStateObjectUpdated(effectiveKey, oldNS, newNS);
+ }
+ else
+ {
+ change = new NavigationalStateObjectCreated(effectiveKey, newNS);
+ }
+ }
+
+ // Store the change
+ if (change != null)
+ {
+ if (changes == null)
+ {
+ changes = new LinkedHashMap();
+ }
+
+ //
+ changes.put(effectiveKey, change);
+ }
+ }
+
+ public Iterator getChanges()
+ {
+ return changes.values().iterator();
+ }
+
+ /**
+ * Apply the navigational state changes to the real storage.
+ *
+ * @return true if state changed
+ */
+ public boolean applyChanges()
+ {
+ if (changes != null && changes.size() > 0)
+ {
+ for (Iterator i = changes.values().iterator();i.hasNext();)
+ {
+ NavigationalStateObjectChange change = (NavigationalStateObjectChange)i.next();
+ if (change instanceof NavigationalStateObjectCreated)
+ {
+ NavigationalStateObjectCreated created = (NavigationalStateObjectCreated)change;
+ store.setAttribute(created.getKey(), created.getValue());
+ }
+ else if (change instanceof NavigationalStateObjectUpdated)
+ {
+ NavigationalStateObjectUpdated updated = (NavigationalStateObjectUpdated)change;
+ store.setAttribute(updated.getKey(), updated.getNewValue());
+ }
+ else
+ {
+ NavigationalStateObjectDestroyed destroyed = (NavigationalStateObjectDestroyed)change;
+ store.setAttribute(destroyed.getKey(), null);
+ }
+ }
+
+ //
+ changes.clear();
+
+ // Increase view id
+ Integer viewId = (Integer)store.getAttribute(VIEW_ID_KEY);
+ if (viewId == null)
+ {
+ viewId = new Integer(0);
+ }
+ else
+ {
+ viewId = new Integer(viewId.intValue() + 1);
+ }
+ store.setAttribute(VIEW_ID_KEY, viewId);
+
+ //
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the current view id.
+ *
+ * @return the view id
+ */
+ public String getViewId()
+ {
+ Integer viewId = (Integer)store.getAttribute(VIEW_ID_KEY);
+ return viewId != null ? viewId.toString() : "0";
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/portal/ns/WindowNavigationalState.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/ns/WindowNavigationalState.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/ns/WindowNavigationalState.java 2007-04-02 21:41:23 UTC (rev 6902)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.core.model.portal.ns;
+
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.StateString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class WindowNavigationalState
+{
+
+ /** . */
+ private final WindowState windowState;
+
+ /** . */
+ private final Mode mode;
+
+ /** . */
+ private final StateString navigationalState;
+
+ public WindowNavigationalState(WindowState windowState, Mode mode, StateString navigationalState)
+ {
+ this.windowState = windowState;
+ this.mode = mode;
+ this.navigationalState = navigationalState;
+ }
+
+ public WindowNavigationalState()
+ {
+ this(WindowState.NORMAL, Mode.VIEW, null);
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+}
17 years, 1 month
JBoss Portal SVN: r6901 - in trunk: core/src/main/org/jboss/portal/core and 22 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-04-02 12:46:19 -0400 (Mon, 02 Apr 2007)
New Revision: 6901
Added:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
trunk/core/src/main/org/jboss/portal/core/ns/
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java
trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java
Removed:
trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java
Modified:
trunk/api/src/main/org/jboss/portal/Mode.java
trunk/api/src/main/org/jboss/portal/WindowState.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java
trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
Log:
- better handling of core command request flow
- introduce real implementation of navigational state context which can log the changes made to the navigational state during a request so it can be used to detect portlet window changes to the nav state and piggy back several portlets to the client side during one request (use case with IPC API)
Modified: trunk/api/src/main/org/jboss/portal/Mode.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/Mode.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/api/src/main/org/jboss/portal/Mode.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class Mode implements Serializable
+public final class Mode implements Serializable
{
/** The serialVersionUID. */
Modified: trunk/api/src/main/org/jboss/portal/WindowState.java
===================================================================
--- trunk/api/src/main/org/jboss/portal/WindowState.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/api/src/main/org/jboss/portal/WindowState.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class WindowState implements Serializable
+public final class WindowState implements Serializable
{
/** The serialVersionUID */
Added: trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/NavigationalStateInterceptor.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * 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.core.aspects.controller;
+
+import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.Controller;
+import org.jboss.portal.core.controller.classic.ClassicController;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
+import org.jboss.portal.common.invocation.InvocationException;
+
+/**
+ * Apply navigational state changes.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateInterceptor extends ControllerInterceptor
+{
+ public Object invoke(ControllerCommand cmd) throws Exception, InvocationException
+ {
+ Object ret = cmd.invokeNext();
+
+ // We commit the nav state changes only for the classic controller at the base of the pipeline
+ ControllerContext controllerContext = cmd.getControllerContext();
+ Controller controller = controllerContext.getController();
+ if (controllerContext.getDepth() == 1 && controller instanceof ClassicController)
+ {
+ PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ ctx.applyChanges();
+ }
+
+ //
+ return ret;
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -50,6 +50,7 @@
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.theme.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.page.Region;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
@@ -124,7 +125,7 @@
//
Region region = rendition.getPageResult().getRegion("navigation");
- region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED, "false");
+ region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
}
}
@@ -143,7 +144,7 @@
//
Region region = rendition.getPageResult().getRegion("dashboardnav");
- region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED, "false");
+ region.setProperty(DynaConstants.OBJECT_ENABLED, "false");
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/node/EventBroadcasterInterceptor.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -25,7 +25,6 @@
import org.apache.log4j.Logger;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
import org.jboss.portal.spi.runtime.NavigationalStateContext;
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.event.PortalNodeEvent;
@@ -45,7 +44,9 @@
import org.jboss.portal.core.model.portal.command.WindowCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.event.PortalEventListenerRegistry;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.StateString;
@@ -342,7 +343,7 @@
private WindowNavigationalState getWNS(PortalNode window, boolean create)
{
PortalObjectNode pon = (PortalObjectNode)window;
- String key = pon.getObjectId().toString() + "_window";
+ NavigationalStateKey key = new NavigationalStateKey(WindowNavigationalState.class, pon.getObjectId());
WindowNavigationalState wns = (WindowNavigationalState)navigationalStateResolver.getAttribute(key);
if (wns == null && create)
{
@@ -383,8 +384,9 @@
}
//
- WindowNavigationalState wns = getWNS(window, true);
- wns.setWindowState(windowState);
+ PortalObjectNode pon = (PortalObjectNode)window;
+ NavigationalStateKey key = new NavigationalStateKey(WindowState.class, pon.getObjectId());
+ navigationalStateResolver.setAttribute(key, windowState);
}
public Mode getMode(PortalNode window) throws IllegalArgumentException
@@ -418,8 +420,9 @@
}
//
- WindowNavigationalState wns = getWNS(window, true);
- wns.setMode(mode);
+ PortalObjectNode pon = (PortalObjectNode)window;
+ NavigationalStateKey key = new NavigationalStateKey(Mode.class, pon.getObjectId());
+ navigationalStateResolver.setAttribute(key, mode);
}
}
}
\ No newline at end of file
Modified: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -25,12 +25,6 @@
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.core.controller.command.mapper.CommandFactory;
import org.jboss.portal.core.controller.command.mapper.URLFactory;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
-import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-import org.jboss.portal.core.controller.classic.HandlerResponse;
-import org.jboss.portal.core.controller.classic.CommandForward;
-import org.jboss.portal.core.controller.classic.HTTPResponse;
-import org.jboss.portal.core.controller.classic.ResponseHandler;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
import org.jboss.portal.core.model.instance.InstanceContainer;
@@ -39,19 +33,12 @@
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.server.RequestController;
-import org.jboss.portal.server.ServerException;
-import org.jboss.portal.server.ServerURL;
-import org.jboss.portal.server.request.URLContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public abstract class Controller extends AbstractJBossService implements RequestController, ResponseHandler
+public abstract class Controller extends AbstractJBossService implements RequestController
{
/** . */
@@ -171,156 +158,5 @@
this.stackFactory = stackFactory;
}
- /**
- * Handle a command which means it executes the command and reacts upon the response created by the command.
- *
- * @param ctx the controller context
- * @param cmd the command
- * @throws org.jboss.portal.server.ServerException
- */
- protected void handleCommand(final ControllerContext ctx, final ControllerCommand cmd) throws ServerException
- {
- HandlerResponse handlerResp = executeCommand(ctx, cmd);
- //
- if (handlerResp == null)
- {
- return;
- }
-
- // Find out if we can execute in the same server invocation
- if (handlerResp instanceof CommandForward)
- {
- CommandForward forward = (CommandForward)handlerResp;
- URLContext urlContext = ctx.getServerInvocation().getServerContext().getURLContext();
- if (requiresRedirect(cmd, urlContext, forward))
- {
- String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(), null);
- sendResponse(ctx, new HTTPResponse.SendRedirect(url));
- }
- else
- {
- handleCommand(ctx, forward.getCommand());
- }
- }
- else
- {
- HTTPResponse hr = (HTTPResponse)handlerResp;
- sendResponse(ctx, hr);
- }
- }
-
- /**
- * All http responses in the stack should be handled here.
- */
- protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
- {
- try
- {
- resp.sendResponse(ctx.getServerInvocation().getServerContext());
- }
- catch (IOException e)
- {
- log.error("Cound not send http response", e);
- }
- catch (ServletException e)
- {
- log.error("Cound not send http response", e);
- }
- }
-
- protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd) throws ServerException
- {
- URLContext urlContext = ctx.getServerInvocation().getServerContext().getURLContext();
-
- try
- {
- // Execute command
- Object commandResponse = ctx.execute(cmd);
-
- // Handle the result, might be null if no handling done
- return handleResponse(ctx, cmd, commandResponse);
- }
- catch (CommandRedirectionException e)
- {
- // Handle the redirection as forward
- return new CommandForward(e.getRedirection(), null);
- }
- catch (InsufficientTransportGuaranteeException e)
- {
- urlContext = URLContext.newInstance(true, urlContext.isAuthenticated());
- ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(), cmd);
- String url = ctx.getServerInvocation().getResponse().renderURL(serverURL, urlContext, null);
- return new HTTPResponse.SendRedirect(url);
- }
- catch (ControllerSecurityException e)
- {
- if (urlContext.isAuthenticated())
- {
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
- }
- else
- {
- urlContext = URLContext.newInstance(urlContext.isSecure(), true);
- ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(), cmd);
- String url = ctx.getServerInvocation().getResponse().renderURL(serverURL, urlContext, null);
- return new HTTPResponse.SendRedirect(url);
- }
- }
- catch (ResourceNotFoundException e)
- {
- log.error("Resource not found " + e.getRef(), e);
- return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
- }
- catch (ControllerException e)
- {
- throw new ServerException(e);
- }
- catch (ServletException e)
- {
- throw new ServerException(e);
- }
- catch (IOException e)
- {
- throw new ServerException(e);
- }
- }
-
- /**
- * Return true if the execution of the next command requires a redirect.
- *
- * @param currentCmd the current command which has been executed
- * @param currentURLCtx the request URL context
- * @param forward the forward
- * @return
- */
- public boolean requiresRedirect(
- ControllerCommand currentCmd,
- URLContext currentURLCtx,
- CommandForward forward)
- {
- CommandInfo currentCmdInfo = currentCmd.getInfo();
- if (currentCmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)currentCmdInfo).isIdempotent())
- {
- return true;
- }
- else
- {
- URLContext nextURLCtx = forward.getURLContext();
- boolean currentAuthenticated = currentURLCtx.isAuthenticated();
- if (nextURLCtx != null && currentAuthenticated != nextURLCtx.isAuthenticated())
- {
- return true;
- }
- else
- {
- boolean currentSecure = currentURLCtx.isSecure();
- if (nextURLCtx != null && nextURLCtx.isSecure() && !currentSecure)
- {
- return true;
- }
- }
- }
- return false;
- }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ControllerContext.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -31,6 +31,7 @@
import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.identity.User;
import org.jboss.portal.core.aspects.server.UserInterceptor;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import java.util.Map;
@@ -47,6 +48,9 @@
/** The controller. */
private Controller controller;
+ /** The depth of the call stack. */
+ private int depth;
+
public ControllerContext(ServerInvocation serverInvocation, Controller controller)
{
if (serverInvocation == null)
@@ -61,11 +65,12 @@
//
this.serverInvocation = serverInvocation;
this.controller = controller;
+ this.depth = 0;
//
addResolver(ControllerCommand.REQUEST_SCOPE, serverInvocation.getContext());
addResolver(ControllerCommand.SESSION_SCOPE, serverInvocation.getContext());
- addResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, serverInvocation.getContext());
+ addResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, new PortalObjectNavigationalStateContext(serverInvocation.getContext().getAttributeResolver(ControllerCommand.PRINCIPAL_SCOPE)));
addResolver(ControllerCommand.PRINCIPAL_SCOPE, serverInvocation.getContext());
}
@@ -80,8 +85,13 @@
command.createContext(this);
//
+ int oldDepth = depth;
+
+ //
try
{
+ depth++;
+
// Execute
InterceptorStack commandStack = controller.getStackFactory().getInterceptorStack();
@@ -95,11 +105,19 @@
}
finally
{
+ //
+ depth = oldDepth;
+
// Call destroy
command.destroyContext();
}
}
+ public int getDepth()
+ {
+ return depth;
+ }
+
/**
* Render the command as an URL or return null if it is not possible.
*
Deleted: trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/InsufficientTransportGuaranteeException.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -1,32 +0,0 @@
-/******************************************************************************
- * 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.core.controller;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class InsufficientTransportGuaranteeException extends ControllerSecurityException
-{
-
-}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -27,7 +27,6 @@
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.classic.HandlerResponse;
-import org.jboss.portal.core.controller.classic.CommandForward;
import org.jboss.portal.core.model.portal.command.MoveWindowCommand;
import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
@@ -38,6 +37,12 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
+import org.jboss.portal.core.ns.NavigationalStateChange;
+import org.jboss.portal.core.ns.NavigationalStateObjectUpdated;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.server.ServerException;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.theme.page.WindowResult;
@@ -48,22 +53,23 @@
import org.jboss.portal.theme.render.WindowRenderContext;
import org.jboss.portal.theme.render.DecorationRenderContext;
import org.jboss.portal.theme.render.PortletRenderContext;
-import org.jboss.portal.theme.render.RenderException;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdateMarkupResponse;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -73,8 +79,40 @@
{
public void handle(ServerInvocation invocation) throws ServerException
{
+ HttpServletRequest req = invocation.getServerContext().getClientRequest();
- HttpServletRequest req = invocation.getServerContext().getClientRequest();
+ //
+ ControllerContext controllerContext = new ControllerContext(invocation, this);
+
+ // Detect any change that would require a total refresh
+ String clientViewId = req.getHeader("view_id");
+ if (clientViewId != null)
+ {
+ PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ String serverViewId = ctx.getViewId();
+ if (!clientViewId.equals(serverViewId))
+ {
+ // todo : that will not work for FORMS submissions, we need a response for the client
+ // to tell to do the request the normal way
+ try
+ {
+ UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(req.getRequestURL().toString());
+ AjaxResponse aresp = new AjaxResponse(dresp);
+ aresp.sendResponse(invocation.getServerContext());
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ catch (ServletException e)
+ {
+ e.printStackTrace();
+ }
+ return;
+ }
+ }
+
+ //
String action = req.getParameter("action");
if ("windowmove".equals(action))
{
@@ -89,11 +127,10 @@
//
PortalObjectId tmp = PortalObjectId.parse(windowId, PortalObjectId.CANONICAL_FORMAT);
- ControllerCommand cmd = new MoveWindowCommand(tmp, fromPosInt, fromRegion, toPosInt, toRegion);
- ControllerContext controllerContext = new ControllerContext(invocation, this);
+ //
try
{
- controllerContext.execute(cmd);
+ controllerContext.execute(new MoveWindowCommand(tmp, fromPosInt, fromRegion, toPosInt, toRegion));
}
catch (ControllerException e)
{
@@ -103,195 +140,307 @@
else
{
// Invoke the chain that creates the initial command
- ControllerCommand cmd = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalHost(), invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
+ ControllerCommand command = commandFactory.doMapping(invocation, invocation.getServerContext().getPortalHost(), invocation.getServerContext().getPortalContextPath(), invocation.getServerContext().getPortalRequestPath());
//
- if (cmd == null)
+ if (command == null)
{
// Handle that case
throw new ServerException("No command was produced by the command factory");
}
- // Create controller context
- ControllerContext ctx = new ControllerContext(invocation, this);
-
// Handle the command created
- handleCommand(ctx, cmd);
- }
- }
-
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
- {
- if (response instanceof PortletWindowResponse)
- {
- PortletWindowResponse pwr = (PortletWindowResponse)response;
- PortletInvocationResponse pir = pwr.getResult();
- if (pir instanceof RenderResponse)
+ try
{
- RenderResponse rr = (RenderResponse)pir;
+ processCommand(controllerContext, command);
}
-
- }
- else if (response instanceof UpdateWindowMarkupResponse)
- {
- UpdateWindowMarkupResponse updateMarkup = (UpdateWindowMarkupResponse)response;
-
- // Figure out if we need a full refresh or not
- boolean fullRefresh;
- if (WindowState.MAXIMIZED.equals(updateMarkup.getNewWindowState()))
+ catch (ControllerException e)
{
- fullRefresh = !WindowState.MAXIMIZED.equals(updateMarkup.getOldWindowState());
+ e.printStackTrace();
}
- else
+ catch (ServletException e)
{
- fullRefresh = WindowState.MAXIMIZED.equals(updateMarkup.getOldWindowState());
+ e.printStackTrace();
}
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
- // We make an assumption here, the window result should carry somehow the window id
- PortalObjectCommand pocmd = (PortalObjectCommand)cmd;
+ /**
+ * Handle a command which means it executes the command and reacts upon the response created by the command.
+ *
+ * @param controllerContext the controller context
+ * @param command the command
+ * @throws org.jboss.portal.server.ServerException
+ */
+ protected void processCommand(final ControllerContext controllerContext, final ControllerCommand command) throws ServerException, ControllerException, ServletException, IOException
+ {
+ Object commandResponse = controllerContext.execute(command);
- //
- ServerInvocation invocation = ctx.getServerInvocation();
+ HandlerResponse handlerResp = processCommandResponse(controllerContext, command, commandResponse);
- // Obtain page and portal
- final Window window = (Window)portalObjectContainer.getObject(pocmd.getTargetId());
- Page page = (Page)window.getParent();
+ //
+ if (handlerResp == null)
+ {
+ return;
+ }
- //
- if (fullRefresh)
- {
- // For now we handle a full page refresh
- RenderPageCommand rpc = new RenderPageCommand(page.getId());
- String url = ctx.renderURL(rpc, null, null);
- UpdatePageResponse dresp = new UpdatePageResponse(url);
- AjaxResponse aresp = new AjaxResponse(dresp);
- aresp.sendResponse(invocation.getServerContext());
- return null;
- }
- else
- {
- RenderWindowCommand rwc = new RenderWindowCommand(updateMarkup.getWindowId());
- return new CommandForward(rwc, null);
- }
+ // Find out if we can execute in the same server invocation
+// if (handlerResp instanceof CommandForward)
+// {
+// CommandForward forward = (CommandForward)handlerResp;
+// URLContext urlContext = controllerContext.getServerInvocation().getServerContext().getURLContext();
+// if (requiresRedirect(command, urlContext, forward))
+// {
+// String url = controllerContext.renderURL(forward.getCommand(), forward.getURLContext(), null);
+// sendResponse(controllerContext, new HTTPResponse.SendRedirect(url));
+// }
+// else
+// {
+// processCommand(controllerContext, forward.getCommand());
+// }
+// }
+// else
+// {
+// }
+ AjaxResponse ar = (AjaxResponse)handlerResp;
+ ar.sendResponse(controllerContext.getServerInvocation().getServerContext());
+ }
+
+ public HandlerResponse processCommandResponse(ControllerContext controllerContext, ControllerCommand command, Object response) throws IOException, ServletException, ServerException
+ {
+ if (response instanceof PortletWindowResponse)
+ {
+// PortletWindowResponse pwr = (PortletWindowResponse)response;
+// PortletInvocationResponse pir = pwr.getResult();
+// if (pir instanceof RenderResponse)
+// {
+// RenderResponse rr = (RenderResponse)pir;
+// }
+ throw new Error("todo");
}
- else if (response instanceof WindowResult)
+ else if (response instanceof UpdateWindowMarkupResponse)
{
- final WindowResult windowResult = (WindowResult)response;
-
// We make an assumption here, the window result should carry somehow the window id
- PortalObjectCommand pocmd = (PortalObjectCommand)cmd;
+ PortalObjectCommand pocmd = (PortalObjectCommand)command;
//
- ServerInvocation invocation = ctx.getServerInvocation();
+ ServerInvocation invocation = controllerContext.getServerInvocation();
// Obtain page and portal
final Window window = (Window)portalObjectContainer.getObject(pocmd.getTargetId());
Page page = (Page)window.getParent();
Portal portal = page.getPortal();
- // Call to the theme framework
- PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
- PageRenderContext prc = new PageRenderContextImpl(res);
+ //
+ PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
- // Obtain layout
- LayoutService layoutService = getPageService().getLayoutService();
- PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+ // The windows marked dirty during the request
+ Set dirtyWindowIds = new HashSet();
+ // Whether we need a full refresh or not
+ boolean refresh = false;
+
//
- WindowRenderContext wrc = new WindowRenderContext()
+ for (Iterator i = ctx.getChanges();i.hasNext();)
{
- public String getId()
- {
- return window.getId().toString();
- }
+ NavigationalStateChange change = (NavigationalStateChange)i.next();
- public int getOrder()
+ //
+ if (change instanceof NavigationalStateObjectUpdated)
{
- return 0;
- }
+ NavigationalStateObjectUpdated update = (NavigationalStateObjectUpdated)change;
- public WindowState getWindowState()
- {
- return windowResult.getWindowState();
- }
+ // Get the state key
+ NavigationalStateKey key = update.getKey();
- public Mode getMode()
- {
- return windowResult.getMode();
- }
-
- public DecorationRenderContext getDecoration()
- {
- return new DecorationRenderContext()
+ // We consider only portal object types
+ if (key.getType() == WindowNavigationalState.class)
{
- public String getId()
- {
- return window.getId().toString();
- }
+ // Get old window state
+ WindowNavigationalState oldNS = (WindowNavigationalState)update.getOldValue();
+ WindowState oldWindowState = oldNS != null ? oldNS.getWindowState() : null;
- public String getTitle()
- {
- return windowResult.getTitle();
+ // Get new window state
+ WindowNavigationalState newNS = (WindowNavigationalState)update.getNewValue();
+ WindowState newWindowState = newNS != null ? newNS.getWindowState() : null;
- }
-
- public Collection getTriggerableActions(String familyName)
+ // Check if window state requires a refresh
+ if (WindowState.MAXIMIZED.equals(oldWindowState))
{
- return windowResult.getTriggerableActions(familyName);
+ if (!WindowState.MAXIMIZED.equals(newWindowState))
+ {
+ refresh = true;
+ }
}
-
- public String getProperty(String name)
+ else if (WindowState.MAXIMIZED.equals(newWindowState))
{
- return (String)windowResult.getWindowProperties().get(name);
+ refresh = true;
}
- };
- }
- public PortletRenderContext getPortlet()
- {
- return new PortletRenderContext()
- {
- public String getMarkup()
+ //
+ if (refresh)
{
- return windowResult.getContent();
+ break;
}
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
+ // Collect the dirty window id
+ dirtyWindowIds.add(key.getId());
+ }
}
-
- public String getProperty(String name)
+ else
{
- return (String)windowResult.getWindowProperties().get(name);
+ // A change that modifies potentially the page structure
+ refresh = true;
+ break;
}
- };
+ }
+ // Commit changes
+ ctx.applyChanges();
+
//
- RenderContext renderCtx = new RenderContext(layout, (MarkupInfo)invocation.getResponse().getContentInfo(), prc, invocation.getRequest());
- try
+ if (refresh)
{
- renderCtx.render(wrc);
+ RenderPageCommand rpc = new RenderPageCommand(page.getId());
+ String url = controllerContext.renderURL(rpc, null, null);
+ UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(url);
+ return new AjaxResponse(dresp);
+ }
+ else
+ {
+ ArrayList windowToRefresh = new ArrayList();
+ for (Iterator i = page.getChildren(PortalObject.WINDOW_MASK).iterator();i.hasNext();)
+ {
+ PortalObject child = (PortalObject)i.next();
+ PortalObjectId childId = child.getId();
+ if (dirtyWindowIds.contains(childId))
+ {
+ windowToRefresh.add(child);
+ }
+ }
+ // Obtain layout
+ LayoutService layoutService = getPageService().getLayoutService();
+ PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+
+ // Call to the theme framework
+ PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
+ PageRenderContext prc = new PageRenderContextImpl(res);
+
//
- DynaResponse dresp = new UpdateMarkupResponse(renderCtx.getMarkupFragment().toString());
- AjaxResponse aresp = new AjaxResponse(dresp);
- aresp.sendResponse(invocation.getServerContext());
- return null;
+ UpdatePageStateResponse updatePage = new UpdatePageStateResponse();
+
+ //
+ for (Iterator i = windowToRefresh.iterator();i.hasNext();)
+ {
+ final PortalObject _window = (PortalObject)i.next();
+ RenderWindowCommand rwc = new RenderWindowCommand(_window.getId());
+ try
+ {
+ Object wresp = controllerContext.execute(rwc);
+ if (wresp instanceof WindowResult)
+ {
+ final WindowResult windowResult = (WindowResult)wresp;
+
+ //
+ WindowRenderContext wrc = new WindowRenderContext()
+ {
+ public String getId()
+ {
+ return _window.getName();
+ }
+
+ public int getOrder()
+ {
+ return 0;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowResult.getWindowState();
+ }
+
+ public Mode getMode()
+ {
+ return windowResult.getMode();
+ }
+
+ public DecorationRenderContext getDecoration()
+ {
+ return new DecorationRenderContext()
+ {
+ public String getId()
+ {
+ return _window.getName();
+ }
+
+ public String getTitle()
+ {
+ return windowResult.getTitle();
+
+ }
+
+ public Collection getTriggerableActions(String familyName)
+ {
+ return windowResult.getTriggerableActions(familyName);
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)windowResult.getWindowProperties().get(name);
+ }
+ };
+ }
+
+ public PortletRenderContext getPortlet()
+ {
+ return new PortletRenderContext()
+ {
+ public String getMarkup()
+ {
+ return windowResult.getContent();
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)windowResult.getWindowProperties().get(name);
+ }
+ };
+ }
+
+ public String getProperty(String name)
+ {
+ return (String)windowResult.getWindowProperties().get(name);
+ }
+ };
+
+ //
+ RenderContext renderCtx = new RenderContext(layout, (MarkupInfo)invocation.getResponse().getContentInfo(), prc);
+ renderCtx.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, Boolean.TRUE);
+ renderCtx.render(wrc);
+ updatePage.addFragment(_window.getName(), renderCtx.getMarkupFragment().toString());
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ return new AjaxResponse(updatePage);
}
- catch (RenderException e)
- {
- e.printStackTrace();
- }
}
else
{
System.out.println("Not yet handled " + response);
+
+ //
+ return null;
}
-
- //
- return null;
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -25,11 +25,11 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.ns.PortalObjectNavigationalStateContext;
import org.jboss.portal.theme.PageRendition;
-import org.jboss.portal.theme.ThemeConstants;
-import org.jboss.portal.server.AbstractServerURL;
-import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@@ -50,8 +50,11 @@
{
RenderPageCommand rpc = (RenderPageCommand)cmd;
+ //
+ ControllerContext controllerContext = rpc.getControllerContext();
+
// If user is logged in and is on dashboard we enable ajax
- if (rpc.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser() != null &&
+ if (controllerContext.getServerInvocation().getServerContext().getClientRequest().getRemoteUser() != null &&
rpc.isDashboard())
{
// Compute the url for the ajax servlet
@@ -66,23 +69,17 @@
url.append(req.getContextPath()).append("/ajax");
//
+ PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+ String viewId = ctx.getViewId();
//
PageRendition rendition = (PageRendition)response;
Map pageProps = rendition.getPageResult().getPageProperties();
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE, "/portal-ajax");
-
- // Compute prefix
-// AbstractServerURL tmp = new AbstractServerURL();
-// tmp.setPortalRequestPath("/");
-// cmd.getControllerContext().getServerInvocation().getServerContext().renderURL(tmp, URLContext.newInstance(false, false));
-
- pageProps.put(ThemeConstants.PORTAL_AJAX_CLASSIC_SERVER_URL, "");
-
-
- pageProps.put(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED, "true");
- pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL, url.toString());
+ pageProps.put(DynaConstants.JAVASCRIPT_BASE, "/portal-ajax");
+ pageProps.put(DynaConstants.OBJECT_ENABLED, "true");
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL, url.toString());
+ pageProps.put(DynaConstants.VIEW_STATE, viewId);
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponse.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -35,7 +35,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class AjaxResponse extends HandlerResponse
+public class AjaxResponse extends HandlerResponse
{
/** . */
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicController.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -22,16 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.controller.classic;
-import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
-import org.jboss.portal.core.controller.command.info.CommandInfo;
import org.jboss.portal.core.controller.Controller;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.CommandRedirectionException;
-import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.InsufficientTransportGuaranteeException;
import org.jboss.portal.core.controller.ControllerSecurityException;
import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.model.portal.PortalObjectResponseHandler;
import org.jboss.portal.core.model.portal.PortletWindowResponseHandler;
import org.jboss.portal.core.model.instance.PortletInstanceResponseHandler;
@@ -74,18 +73,18 @@
}
// Create controller context
- ControllerContext ctx = new ControllerContext(invocation, this);
+ ControllerContext controllerContext = new ControllerContext(invocation, this);
// Handle the command created
- handleCommand(ctx, cmd);
+ processCommand(controllerContext, cmd);
}
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
{
for (int i = 0;i < handlers.length;i++)
{
ResponseHandler handler = handlers[i];
- HandlerResponse handlerResponse = handler.handleResponse(ctx, cmd, response);
+ HandlerResponse handlerResponse = handler.processCommandResponse(ctx, cmd, response);
if (handlerResponse != null)
{
return handlerResponse;
@@ -95,4 +94,150 @@
//
return null;
}
+
+ protected HandlerResponse executeCommand(ControllerContext ctx, ControllerCommand cmd) throws ServerException
+ {
+ URLContext urlContext = ctx.getServerInvocation().getServerContext().getURLContext();
+
+ try
+ {
+ // Execute command
+ Object commandResponse = ctx.execute(cmd);
+
+ // Handle the result, might be null if no handling done
+ return processCommandResponse(ctx, cmd, commandResponse);
+ }
+ catch (CommandRedirectionException e)
+ {
+ // Handle the redirection as forward
+ return new CommandForward(e.getRedirection(), null);
+ }
+ catch (ControllerSecurityException e)
+ {
+ if (urlContext.isAuthenticated())
+ {
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
+ }
+ else
+ {
+ urlContext = URLContext.newInstance(urlContext.isSecure(), true);
+ ServerURL serverURL = getURLFactory().doMapping(ctx.getServerInvocation(), cmd);
+ String url = ctx.getServerInvocation().getResponse().renderURL(serverURL, urlContext, null);
+ return new HTTPResponse.SendRedirect(url);
+ }
+ }
+ catch (ResourceNotFoundException e)
+ {
+ log.error("Resource not found " + e.getRef(), e);
+ return new HTTPResponse.SetStatusCode(HttpServletResponse.SC_NOT_FOUND);
+ }
+ catch (ControllerException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (ServletException e)
+ {
+ throw new ServerException(e);
+ }
+ catch (IOException e)
+ {
+ throw new ServerException(e);
+ }
+ }
+
+ /**
+ * Return true if the execution of the next command requires a redirect.
+ *
+ * @param currentCmd the current command which has been executed
+ * @param currentURLCtx the request URL context
+ * @param forward the forward
+ * @return
+ */
+ public boolean requiresRedirect(
+ ControllerCommand currentCmd,
+ URLContext currentURLCtx,
+ CommandForward forward)
+ {
+ CommandInfo currentCmdInfo = currentCmd.getInfo();
+ if (currentCmdInfo instanceof ActionCommandInfo && !((ActionCommandInfo)currentCmdInfo).isIdempotent())
+ {
+ return true;
+ }
+ else
+ {
+ URLContext nextURLCtx = forward.getURLContext();
+ boolean currentAuthenticated = currentURLCtx.isAuthenticated();
+ if (nextURLCtx != null && currentAuthenticated != nextURLCtx.isAuthenticated())
+ {
+ return true;
+ }
+ else
+ {
+ boolean currentSecure = currentURLCtx.isSecure();
+ if (nextURLCtx != null && nextURLCtx.isSecure() && !currentSecure)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Handle a command which means it executes the command and reacts upon the response created by the command.
+ *
+ * @param ctx the controller context
+ * @param cmd the command
+ * @throws org.jboss.portal.server.ServerException
+ */
+ protected void processCommand(final ControllerContext ctx, final ControllerCommand cmd) throws ServerException
+ {
+ HandlerResponse handlerResp = executeCommand(ctx, cmd);
+
+ //
+ if (handlerResp == null)
+ {
+ return;
+ }
+
+ // Find out if we can execute in the same server invocation
+ if (handlerResp instanceof CommandForward)
+ {
+ CommandForward forward = (CommandForward)handlerResp;
+ URLContext urlContext = ctx.getServerInvocation().getServerContext().getURLContext();
+ if (requiresRedirect(cmd, urlContext, forward))
+ {
+ String url = ctx.renderURL(forward.getCommand(), forward.getURLContext(), null);
+ sendResponse(ctx, new HTTPResponse.SendRedirect(url));
+ }
+ else
+ {
+ processCommand(ctx, forward.getCommand());
+ }
+ }
+ else
+ {
+ HTTPResponse hr = (HTTPResponse)handlerResp;
+ sendResponse(ctx, hr);
+ }
+ }
+
+ /**
+ * All http responses in the stack should be handled here.
+ */
+ protected void sendResponse(ControllerContext ctx, HTTPResponse resp)
+ {
+ try
+ {
+ resp.sendResponse(ctx.getServerInvocation().getServerContext());
+ }
+ catch (IOException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ catch (ServletException e)
+ {
+ log.error("Cound not send http response", e);
+ }
+ }
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ClassicResponseHandler.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -48,7 +48,7 @@
private PortalObjectId defaultPortalPath = PortalObjectId.parse("/default", PortalObjectId.CANONICAL_FORMAT);
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
{
final ServerInvocation invocation = ctx.getServerInvocation();
if (response instanceof PageRendition)
Modified: trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/classic/ResponseHandler.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -35,5 +35,5 @@
*/
public interface ResponseHandler
{
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException;
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException;
}
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/PortletResponseHandler.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -61,7 +61,7 @@
StateString navState,
PortletResponse response);
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
{
if (response instanceof PortletResponse)
{
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -32,17 +32,18 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.model.portal.content.ContentRenderer;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.controller.ResourceNotFoundException;
import org.jboss.portal.core.controller.ControllerException;
import org.jboss.portal.core.controller.ResourceAccessDeniedException;
import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.server.config.ServerConfig;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
-import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Properties;
@@ -55,7 +56,6 @@
import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -151,23 +151,19 @@
Portal portal = cmd.getPortal();
ControllerContext context = cmd.getControllerContext();
ServerConfig cfg = context.getServerInvocation().getRequest().getServer().getConfig();
+
PortalObjectId windowId = window.getId();
- StateString navigationalState = (StateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, windowId);
- String navStateKey = windowId + "_window";
- WindowNavigationalState windowNavState = (WindowNavigationalState)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, navStateKey);
+ NavigationalStateKey nsKey = new NavigationalStateKey(WindowNavigationalState.class, windowId);
+ WindowNavigationalState windowNS = (WindowNavigationalState)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey);
//
- if (windowNavState == null)
+ if (windowNS == null)
{
- windowNavState = new WindowNavigationalState();
- context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, navStateKey, windowNavState);
+ windowNS = new WindowNavigationalState(WindowState.NORMAL, Mode.VIEW, null);
+ context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey, windowNS);
}
//
- Mode mode = windowNavState.getMode();
- WindowState windowState = windowNavState.getWindowState();
-
- //
String windowTitle;
String contentChars;
String headerChars = null;
@@ -199,9 +195,9 @@
// Create invocation
RenderInvocation invocation = PortletInvocationFactory.createRender(
context,
- mode,
- windowState,
- navigationalState,
+ windowNS.getMode(),
+ windowNS.getWindowState(),
+ windowNS.getNavigationalState(),
window,
portal);
@@ -269,10 +265,10 @@
}
//
- addModeActions(context, window, actionMap, windowNavState.getMode(), supportedModes);
+ addModeActions(context, window, actionMap, windowNS.getMode(), supportedModes);
//
- addStateActions(context, window, actionMap, windowNavState.getWindowState(), supportedWindowStates);
+ addStateActions(context, window, actionMap, windowNS.getWindowState(), supportedWindowStates);
//
contentChars = fragment.getContent();
@@ -285,8 +281,8 @@
windowProps,
new Properties(),
headerChars,
- windowNavState.getWindowState(),
- windowNavState.getMode());
+ windowNS.getWindowState(),
+ windowNS.getMode());
}
else if (response instanceof ErrorResponse)
{
@@ -303,7 +299,7 @@
{
contentChars = Exceptions.toHTML(t, true);
}
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
else if (response instanceof UnavailableResponse)
@@ -315,7 +311,7 @@
actionMap = new HashMap();
actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
else if (response instanceof InsufficientPrivilegesResponse)
@@ -340,7 +336,7 @@
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Access denied";
contentChars = "Access denied";
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
catch (ResourceNotFoundException e)
@@ -355,7 +351,7 @@
actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
windowTitle = "Cannot render";
contentChars = "Object not found " + e.getRef();
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
catch (ControllerException e)
@@ -371,7 +367,7 @@
{
windowTitle = "An internal error occured while rendering window '" + window + "'";
contentChars = Exceptions.toHTML(e, true);
- return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNavState.getWindowState(), windowNavState.getMode());
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps, new Properties(), headerChars, windowNS.getWindowState(), windowNS.getMode());
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -35,7 +35,9 @@
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.core.impl.model.content.InternalContentProvider;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.StateString;
import org.jboss.portal.theme.page.WindowResult;
import org.jboss.portal.Mode;
import org.jboss.portal.common.i18n.LocalizedString;
@@ -165,7 +167,8 @@
}
// Initialize the navigational state with the URI when needed
- PortletParametersStateString navigationalState = (PortletParametersStateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, windowId);
+ NavigationalStateKey nsKey = new NavigationalStateKey(StateString.class, windowId);
+ PortletParametersStateString navigationalState = (PortletParametersStateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey);
if (navigationalState == null || !content.getURI().equals(navigationalState.getValue("uri")))
{
navigationalState = new PortletParametersStateString();
@@ -183,7 +186,7 @@
navigationalState.setValue("uri", uri);
//
- context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, windowId, navigationalState);
+ context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, nsKey, navigationalState);
}
//
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -30,13 +30,14 @@
import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.ImportPageToDashboardCommand;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.servlet.PathMapping;
import org.jboss.portal.server.servlet.PathMappingResult;
import org.jboss.portal.server.servlet.PathParser;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
/**
* This command mapper is used to map portal objects living in a container to <code>org.jboss.portal.core.command.RenderPageCommand</code>
@@ -118,11 +119,12 @@
decoder.decode(queryParams, invocation.getServerContext().getBodyParameterMap());
// Get the window navigational state
- WindowNavigationalState windowNavState = (WindowNavigationalState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window");
+ NavigationalStateKey nsKey = new NavigationalStateKey(WindowNavigationalState.class, window.getId());
+ WindowNavigationalState windowNavState = (WindowNavigationalState)invocation.getAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, nsKey);
if (windowNavState == null)
{
windowNavState = new WindowNavigationalState();
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, window.getId() + "_window", windowNavState);
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, nsKey, windowNavState);
}
//
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectResponseHandler.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -42,7 +42,7 @@
public class PortalObjectResponseHandler extends AbstractResponseHandler
{
- public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
+ public HandlerResponse processCommandResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
{
if (response instanceof UpdateViewResponse)
{
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -30,8 +30,9 @@
import org.jboss.portal.core.controller.command.info.ViewCommandInfo;
import org.jboss.portal.core.model.portal.command.response.UpdateWindowMarkupResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
+import org.jboss.portal.core.ns.NavigationalStateKey;
import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
/**
* Simply update the navigational state of the window. No invocation to the underlying is done.
@@ -82,48 +83,42 @@
{
InvocationContext ctx = getContext();
PortalObjectId windowId = window.getId();
+ NavigationalStateKey nsKey = new NavigationalStateKey(WindowNavigationalState.class, windowId);
//
- if (navigationalState != null)
- {
- ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId, navigationalState);
- }
+ WindowNavigationalState oldNS = (WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey);
//
- WindowState oldWS = null;
- Mode oldMode = null;
+ StateString newState = oldNS != null ? oldNS.getNavigationalState() : null;
+ WindowState newWindowState = oldNS != null ? oldNS.getWindowState() : null;
+ Mode newMode = oldNS != null ? oldNS.getMode() : null;
- // Update the window nav state
- WindowNavigationalState windowNS = (WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window");
- if (windowNS == null)
+ //
+ if (navigationalState != null)
{
- windowNS = new WindowNavigationalState();
- ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window", windowNS);
+ newState = navigationalState;
}
- else
- {
- oldWS = windowNS.getWindowState();
- oldMode = windowNS.getMode();
- }
//
- if (mode != null)
+ if (this.mode != null)
{
- windowNS.setMode(mode);
+ newMode = this.mode;
}
//
- if (windowState != null)
+ if (this.windowState != null)
{
- windowNS.setWindowState(windowState);
+ newWindowState = this.windowState;
}
+ // Create new NS
+ WindowNavigationalState newNS = new WindowNavigationalState(newWindowState, newMode, newState);
+
+ // Update NS
+ ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, nsKey, newNS);
+
+
//
- return new UpdateWindowMarkupResponse(
- windowId,
- oldWS,
- windowNS.getWindowState(),
- oldMode,
- windowNS.getMode());
+ return new UpdateWindowMarkupResponse(windowId, oldNS, newNS);
}
}
\ No newline at end of file
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -234,9 +234,9 @@
WindowResult result = (WindowResult)res;
String region = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION);
String order = window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER);
- WindowContext wc = new WindowContext(window.getName(), window.getId(), region, Integer.parseInt(order));
+ WindowContext wc = new WindowContext(window.getName(), window.getName(), region, Integer.parseInt(order));
pageResult.addWindowContext(wc);
- pageResult.addWindowResult(window.getId(), result);
+ pageResult.addWindowResult(window.getName(), result);
}
else
{
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.model.portal.command.response;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.ns.WindowNavigationalState;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
@@ -36,34 +37,22 @@
/** . */
private final PortalObjectId windowId;
- /** If not null indicate the previous window state. */
- private final WindowState oldWindowState;
+ /** If not null indicate the previous state. */
+ private final WindowNavigationalState oldNavigationalState;
- /** Indicate the current window state. */
- private final WindowState newWindowState;
+ /** Indicate the current state. */
+ private final WindowNavigationalState newNavigationalState;
- /** If not null indicate the previous mode. */
- private final Mode oldMode;
- /** Indicate the current mode. */
- private final Mode newMode;
-
- public UpdateWindowMarkupResponse(
- PortalObjectId windowId,
- WindowState oldWindowState,
- WindowState newWindowState,
- Mode oldMode,
- Mode newMode)
+ public UpdateWindowMarkupResponse(PortalObjectId windowId, WindowNavigationalState oldNavigationalState, WindowNavigationalState newNavigationalState)
{
if (windowId == null)
{
throw new IllegalArgumentException();
}
this.windowId = windowId;
- this.oldWindowState = oldWindowState;
- this.newWindowState = newWindowState;
- this.oldMode = oldMode;
- this.newMode = newMode;
+ this.oldNavigationalState = oldNavigationalState;
+ this.newNavigationalState = newNavigationalState;
}
public PortalObjectId getWindowId()
@@ -73,21 +62,21 @@
public WindowState getOldWindowState()
{
- return oldWindowState;
+ return oldNavigationalState != null ? oldNavigationalState.getWindowState() : null;
}
public WindowState getNewWindowState()
{
- return newWindowState;
+ return newNavigationalState.getWindowState();
}
public Mode getOldMode()
{
- return oldMode;
+ return oldNavigationalState != null ? oldNavigationalState.getMode() : null;
}
public Mode getNewMode()
{
- return newMode;
+ return newNavigationalState.getMode();
}
}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChange.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateChange
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateChangeListener.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * 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.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NavigationalStateChangeListener
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateContext.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.core.ns;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface NavigationalStateContext extends AttributeResolver
+{
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateKey.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * 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.core.ns;
+
+/**
+ * A key for navigational state.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class NavigationalStateKey
+{
+
+ /** The type. */
+ private final Class type;
+
+ /** The id. */
+ private final Object id;
+
+ public NavigationalStateKey(Class type, Object id)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type provided");
+ }
+ if (id == null)
+ {
+ throw new IllegalArgumentException("No id provided");
+ }
+ this.type = type;
+ this.id = id;
+ }
+
+ public Class getType()
+ {
+ return type;
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof NavigationalStateKey)
+ {
+ NavigationalStateKey that = (NavigationalStateKey)obj;
+ return type.equals(that.type) && id.equals(that.id);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return type.hashCode() + id.hashCode();
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectChange.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectChange extends NavigationalStateChange
+{
+
+ /** . */
+ private NavigationalStateKey key;
+
+ public NavigationalStateObjectChange(NavigationalStateKey key)
+ {
+ this.key = key;
+ }
+
+ public NavigationalStateKey getKey()
+ {
+ return key;
+ }
+
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectCreated.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectCreated extends NavigationalStateObjectChange
+{
+
+ /** . */
+ private final Object value;
+
+ public NavigationalStateObjectCreated(NavigationalStateKey key, Object value)
+ {
+ super(key);
+ this.value = value;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectDestroyed.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * 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.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectDestroyed extends NavigationalStateObjectChange
+{
+
+ /** . */
+ private final Object value;
+
+ public NavigationalStateObjectDestroyed(NavigationalStateKey key, Object value)
+ {
+ super(key);
+ this.value = value;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/ns/NavigationalStateObjectUpdated.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * 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.core.ns;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NavigationalStateObjectUpdated extends NavigationalStateObjectChange
+{
+
+ /** . */
+ private final Object oldValue;
+
+ /** . */
+ private final Object newValue;
+
+ public NavigationalStateObjectUpdated(NavigationalStateKey key, Object oldValue, Object newValue)
+ {
+ super(key);
+ this.oldValue = oldValue;
+ this.newValue = newValue;
+ }
+
+ public Object getOldValue()
+ {
+ return oldValue;
+ }
+
+ public Object getNewValue()
+ {
+ return newValue;
+ }
+}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-04-02 16:46:19 UTC (rev 6901)
@@ -155,6 +155,20 @@
<!-- Command stack -->
<mbean
+ code="org.jboss.portal.core.controller.ajax.AjaxInterceptor"
+ name="portal:service=Interceptor,type=Command,name=Ajax"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.core.aspects.controller.NavigationalStateInterceptor"
+ name="portal:service=Interceptor,type=Command,name=NavigationalState"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
code="org.jboss.portal.core.aspects.controller.node.PortalNodeInterceptor"
name="portal:service=Interceptor,type=Command,name=PortalNode"
xmbean-dd=""
@@ -179,13 +193,6 @@
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.controller.ajax.AjaxInterceptor"
- name="portal:service=Interceptor,type=Command,name=Ajax"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- </mbean>
- <mbean
code="org.jboss.portal.core.aspects.controller.node.EventBroadcasterInterceptor"
name="portal:service=Interceptor,type=Command,name=EventBroadcaster"
xmbean-dd=""
@@ -202,10 +209,11 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<depends-list optional-attribute-name="InterceptorNames">
+ <depends-list-element>portal:service=Interceptor,type=Command,name=Ajax</depends-list-element>
+ <depends-list-element>portal:service=Interceptor,type=Command,name=NavigationalState</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PageCustomizer</depends-list-element>
- <depends-list-element>portal:service=Interceptor,type=Command,name=Ajax</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=EventBroadcaster</depends-list-element>
</depends-list>
</mbean>
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-02 16:46:19 UTC (rev 6901)
@@ -98,25 +98,40 @@
}
//
+ var headers = ["ajax","true"];
+ if (view_state !== undefined)
+ {
+ headers.view_state = view_state;
+ }
+
+ //
var options = {
parameters:parameters,
asynchronous:true,
method: method,
postBody: body,
- requestHeaders:["ajax","true"],
+ requestHeaders:headers,
onSuccess: function(t)
{
var resp = "";
eval("resp =" + t.responseText + ";");
if (resp.type == "update_markup")
{
- var markup = resp.markup;
+ // Iterate all changes
+ for (var id in resp.fragments)
+ {
+ var matchingElts = document.getElementsByClassName(id);
- // Remove the div
- markup = markup.substring(31, markup.length - 6);
+ // Different than 1 is not good
+ if (matchingElts.length == 1)
+ {
+ var markup = resp.fragments[id];
+ markup = markup.substring(25, markup.length - 7);
- //
- container.innerHTML = markup;
+ var markupContainer = Element.up(matchingElts[0]);
+ markupContainer.innerHTML = markup;
+ }
+ }
}
else if (resp.type == "update_page")
{
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/TestHelper.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -37,7 +37,6 @@
import org.jboss.portal.theme.impl.page.PageServiceImpl;
import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
import org.jboss.portal.theme.metadata.RenderSetMetaData;
-import org.jboss.portal.theme.navigation.WindowNavigationalState;
import org.jboss.portal.theme.page.PageResult;
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.theme.page.WindowContext;
@@ -132,13 +131,6 @@
return new WindowResult(title, content, actionsMap, windowProps, responseProps, headerChars, null, null);
}
- public static WindowNavigationalState createWindowNavigationalState()
- {
- WindowState windowState = WindowState.NORMAL;
- Mode portletMode = Mode.VIEW;
- return new WindowNavigationalState(windowState, portletMode);
- }
-
public static RenderSetMetaData createRenderSetMD() throws Exception
{
List renderSets = (List)UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(createRenderSetDescriptor(), new RenderSetMetaDataFactory(), null);
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/render/TestRenderedMarkup.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -39,6 +39,7 @@
import org.jboss.portal.theme.deployment.jboss.RenderSetMetaDataFactory;
import org.jboss.portal.theme.impl.LayoutServiceImpl;
import org.jboss.portal.theme.impl.ThemeServiceImpl;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.metadata.PortalLayoutMetaData;
import org.jboss.portal.theme.metadata.PortalThemeMetaData;
import org.jboss.portal.theme.metadata.RenderSetMetaData;
@@ -127,8 +128,8 @@
{
//
Map pageProps = new HashMap();
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE, "/portal-ajax");
- pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL, "http://localhost:8080/portal-ajax/ajax");
+ pageProps.put(DynaConstants.JAVASCRIPT_BASE, "/portal-ajax");
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL, "http://localhost:8080/portal-ajax/ajax");
//
Map portalProps = new HashMap();
Modified: trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/test/theme/servlet/TestThemeServlet.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -35,6 +35,7 @@
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.impl.render.dynamic.DynaConstants;
import org.jboss.portal.theme.page.PageService;
import org.jboss.portal.theme.page.WindowContext;
import org.jboss.portal.theme.page.WindowResult;
@@ -98,8 +99,8 @@
//
Map pageProps = new HashMap();
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE, "/portal-ajax");
- pageProps.put(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL, "http://localhost:8080/portal-ajax/ajax");
+ pageProps.put(DynaConstants.JAVASCRIPT_BASE, "/portal-ajax");
+ pageProps.put(DynaConstants.ASYNC_SERVER_URL, "http://localhost:8080/portal-ajax/ajax");
//
Map portalProps = new HashMap();
@@ -129,7 +130,7 @@
}
// set the renderctx and req/res attr
- RenderContext renderCtx = new RenderContext(layout, markupInfo, new PageRenderContextImpl(pageResult), serverRequest);
+ RenderContext renderCtx = new RenderContext(layout, markupInfo, new PageRenderContextImpl(pageResult));
response.setContentType(renderCtx.getContentType().toString());
response.setCharacterEncoding(renderCtx.getCharset());
request.setAttribute(LayoutConstants.ATTR_RENDERCONTEXT, renderCtx);
Modified: trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/PortalLayout.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -103,6 +103,6 @@
*/
public RenderContext getRenderContext(MarkupInfo markupInfo, ServerRequest request, PageResult markupResult)
{
- return new RenderContext(this, markupInfo, new PageRenderContextImpl(markupResult), request);
+ return new RenderContext(this, markupInfo, new PageRenderContextImpl(markupResult));
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -83,23 +83,4 @@
*/
public static final String PORTAL_PROP_REGION = "theme.region";
- /**
- *
- */
- public static final String PORTAL_AJAX_JAVASCRIPT_BASE = "theme.ajax.js_base";
-
- /**
- *
- */
- public static final String PORTAL_AJAX_ASYNC_SERVER_URL = "theme.ajax.async_server_url";
-
- /**
- *
- */
- public static final String PORTAL_AJAX_CLASSIC_SERVER_URL = "theme.ajax.classic_server_url";
-
- /**
- *
- */
- public static final String PORTAL_AJAX_OBJECT_ENABLED = "theme.ajax.object_enabled";
}
Added: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaConstants.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * 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.theme.impl.render.dynamic;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public final class DynaConstants
+{
+
+ /** . */
+ public static final String JAVASCRIPT_BASE = "theme.ajax.js_base";
+
+ /** . */
+ public static final String ASYNC_SERVER_URL = "theme.ajax.async_server_url";
+
+ /** . */
+ public static final String OBJECT_ENABLED = "theme.ajax.object_enabled";
+
+ /** The id for view state. */
+ public static final String VIEW_STATE = "theme.ajax.view_state";
+
+ /** . */
+ public static final String AJAX_WINDOW_ENABLED = "ajax_window_enabled";
+
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaDecorationRenderer.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -49,7 +49,7 @@
public void render(RenderContext renderContext, DecorationRenderContext drc) throws RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
//
DynaWindowRenderer.handleProvided.set(Boolean.TRUE);
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaPortletRenderer.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -56,7 +56,7 @@
private void doDND(RenderContext renderContext, PortletRenderContext prc) throws RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
// Provide handle on content if needed
if (Boolean.FALSE.equals(DynaWindowRenderer.handleProvided.get()))
@@ -83,7 +83,7 @@
private void doCatchClicks(RenderContext renderContext, PortletRenderContext prc) throws RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
StringBuffer out = renderContext.getMarkupFragment();
out.append("<div class=\"dyna-portlet\">");
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -45,7 +45,6 @@
package org.jboss.portal.theme.impl.render.dynamic;
-import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.render.RegionRenderer;
import org.jboss.portal.theme.render.RenderContext;
import org.jboss.portal.theme.render.RenderException;
@@ -62,16 +61,8 @@
{
/** . */
- private static final ThreadLocal enabledLocal = new ThreadLocal();
-
- /** . */
private RegionRenderer delegate;
- public static boolean isEnabled()
- {
- return Boolean.TRUE == enabledLocal.get();
- }
-
public DynaRegionRenderer(RegionRenderer regionRenderer) throws InstantiationException,
IllegalAccessException, ClassNotFoundException
{
@@ -83,12 +74,12 @@
public void renderHeader(RenderContext renderContext, RegionRenderContext rrc) throws RenderException
{
StringBuffer markup = renderContext.getMarkupFragment();
- String jsBase = renderContext.getProperty(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE);
- String asyncServerURL = renderContext.getProperty(ThemeConstants.PORTAL_AJAX_ASYNC_SERVER_URL);
- String classicServerURL = renderContext.getProperty(ThemeConstants.PORTAL_AJAX_CLASSIC_SERVER_URL);
+ String jsBase = renderContext.getProperty(DynaConstants.JAVASCRIPT_BASE);
+ String asyncServerURL = renderContext.getProperty(DynaConstants.ASYNC_SERVER_URL);
+ String viewState = renderContext.getProperty(DynaConstants.VIEW_STATE);
//
- Object onPage = renderContext.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
+ Object onPage = renderContext.getProperty(DynaConstants.OBJECT_ENABLED);
boolean pageEnabled = onPage != null && "true".equals(onPage);
//
@@ -98,17 +89,24 @@
// Handle special ajax region here
if ("AJAXScripts".equals(rrc.getId()))
{
- markup.append("\n\n\n");
markup.append("<script type='text/javascript' src='").append(jsBase).append("/js/portal/prototype.js'></script>\n");
markup.append("<script type='text/javascript' src='").append(jsBase).append("/js/portal/scriptaculous.js'></script>\n");
markup.append("<script type='text/javascript' src='").append(jsBase).append("/js/portal/effects.js'></script>\n");
markup.append("<script type='text/javascript' src='").append(jsBase).append("/js/portal/dragdrop.js'></script>\n");
markup.append("<script type='text/javascript' src='").append(jsBase).append("/js/portal/dyna.js'></script>\n");
markup.append("<script type='text/javascript'>\n");
+
+ // Async server URL needed for callbacks
markup.append("async_server_url=\"").append(asyncServerURL).append(";\"\n");
- markup.append("classic_server_url=\"").append(classicServerURL).append("\";\n");
+
+ // View state if not null
+ if (viewState != null)
+ {
+ markup.append("view_state=\"").append(viewState).append("\";\n");
+ }
+
+ //
markup.append("</script>\n");
- markup.append("\n\n\n");
}
else if ("AJAXFooter".equals(rrc.getId()))
{
@@ -116,13 +114,13 @@
}
else
{
- String onRegion = rrc.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
+ String onRegion = rrc.getProperty(DynaConstants.OBJECT_ENABLED);
regionEnabled = onRegion == null || "true".equals(onRegion);
}
}
- // Set up thread local
- enabledLocal.set(Boolean.valueOf(regionEnabled));
+ //
+ renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, Boolean.valueOf(regionEnabled));
//
if (regionEnabled)
@@ -142,7 +140,7 @@
public void renderFooter(RenderContext renderContext, RegionRenderContext rrc) throws RenderException
{
//
- if (isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
StringBuffer markup = renderContext.getMarkupFragment();
@@ -154,7 +152,7 @@
delegate.renderFooter(renderContext, rrc);
//
- enabledLocal.set(null);
+ renderContext.setAttribute(DynaConstants.AJAX_WINDOW_ENABLED, null);
}
/**
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaWindowRenderer.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -54,15 +54,16 @@
/** @see WindowRenderer#render */
public void render(RenderContext renderContext, WindowRenderContext wrc) throws RenderException
{
- if (DynaRegionRenderer.isEnabled())
+ if (Boolean.TRUE == renderContext.getAttribute(DynaConstants.AJAX_WINDOW_ENABLED))
{
// For now we say we have no provided any handle so far for the window
handleProvided.set(Boolean.FALSE);
//
- renderContext.getMarkupFragment().append("<div class=\"dyna-window\">\n");
+ StringBuffer out = renderContext.getMarkupFragment();
+ out.append("<div class=\"dyna-window").append("\"><div class=\"").append(wrc.getId()).append("\"/>\n");
delegate.render(renderContext, wrc);
- renderContext.getMarkupFragment().append("</div>\n");
+ out.append("</div></div>\n");
//
handleProvided.set(null);
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/JSONMarshaller.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.theme.impl.render.dynamic;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdateMarkupResponse;
-import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageStateResponse;
+import org.jboss.portal.theme.impl.render.dynamic.response.UpdatePageLocationResponse;
import org.jboss.portal.theme.impl.render.dynamic.json.JSONWriter;
import org.jboss.portal.theme.impl.render.dynamic.json.JSONException;
import java.io.Writer;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -43,17 +45,33 @@
try
{
- if (response instanceof UpdateMarkupResponse)
+ if (response instanceof UpdatePageStateResponse)
{
- UpdateMarkupResponse umr = (UpdateMarkupResponse)response;
+ UpdatePageStateResponse umr = (UpdatePageStateResponse)response;
+
+ //
writer.object();
+
+ //
writer.key("type").value("update_markup");
- writer.key("markup").value(umr.getMarkup());
+
+ //
+ writer.key("fragments").object();
+ for (Iterator i = umr.getFragments().entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String id = (String)entry.getKey();
+ String fragment = (String)entry.getValue();
+ writer.key(id).value(fragment);
+ }
writer.endObject();
+
+ //
+ writer.endObject();
}
- else if (response instanceof UpdatePageResponse)
+ else if (response instanceof UpdatePageLocationResponse)
{
- UpdatePageResponse upr = (UpdatePageResponse)response;
+ UpdatePageLocationResponse upr = (UpdatePageLocationResponse)response;
writer.object();
writer.key("type").value("update_page");
writer.key("location").value(upr.getLocation());
Deleted: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -1,50 +0,0 @@
-/******************************************************************************
- * 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.theme.impl.render.dynamic.response;
-
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UpdateMarkupResponse extends DynaResponse
-{
-
- /** . */
- private String markup;
-
- public UpdateMarkupResponse(String markup)
- {
- if (markup == null)
- {
- throw new IllegalArgumentException();
- }
- this.markup = markup;
- }
-
- public String getMarkup()
- {
- return markup;
- }
-}
Copied: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java (from rev 6899, trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageLocationResponse.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * 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.theme.impl.render.dynamic.response;
+
+import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UpdatePageLocationResponse extends DynaResponse
+{
+
+ /** . */
+ private final String location;
+
+ public UpdatePageLocationResponse(String location)
+ {
+ this.location = location;
+ }
+
+ public String getLocation()
+ {
+ return location;
+ }
+}
Deleted: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageResponse.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -1,46 +0,0 @@
-/******************************************************************************
- * 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.theme.impl.render.dynamic.response;
-
-import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class UpdatePageResponse extends DynaResponse
-{
-
- /** . */
- private final String location;
-
- public UpdatePageResponse(String location)
- {
- this.location = location;
- }
-
- public String getLocation()
- {
- return location;
- }
-}
Copied: trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java (from rev 6899, trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdateMarkupResponse.java)
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java (rev 0)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/response/UpdatePageStateResponse.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.theme.impl.render.dynamic.response;
+
+import org.jboss.portal.theme.impl.render.dynamic.DynaResponse;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UpdatePageStateResponse extends DynaResponse
+{
+
+ /** . */
+ private Map fragments;
+
+ public UpdatePageStateResponse()
+ {
+ fragments = new HashMap();
+ }
+
+ public void addFragment(String id, String fragment)
+ {
+ fragments.put(id, fragment);
+ }
+
+ public Map getFragments()
+ {
+ return Collections.unmodifiableMap(fragments);
+ }
+}
Modified: trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/page/WindowContext.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -53,22 +53,12 @@
/** . */
private int order;
- /** . */
- private boolean visible;
-
- public static WindowContext copy(WindowContext template)
+ public WindowContext(String windowName, String windowId, String regionName, int order)
{
- return new WindowContext(template.windowName, template.windowId, template.regionName, template.order);
- }
-
- public WindowContext(String windowName, Object windowId, String regionName, int order)
- {
this.windowName = windowName;
this.windowId = windowId;
this.regionName = regionName;
this.order = order;
- // by default the window is visible
- this.visible = true;
}
public String getWindowName()
@@ -101,16 +91,6 @@
this.order = order;
}
- public boolean isVisible()
- {
- return visible;
- }
-
- public void setVisible(boolean visible)
- {
- this.visible = visible;
- }
-
public int compareTo(Object o)
{
return order - ((WindowContext)o).order;
@@ -139,6 +119,6 @@
public String toString()
{
- return windowName + " " + windowId + " " + regionName + " " + order + " " + (visible ? "visible" : "invisible");
+ return windowName + " " + windowId + " " + regionName + " " + order;
}
}
Modified: trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-04-02 15:22:03 UTC (rev 6900)
+++ trunk/theme/src/main/org/jboss/portal/theme/render/RenderContext.java 2007-04-02 16:46:19 UTC (rev 6901)
@@ -24,14 +24,13 @@
import org.jboss.portal.common.util.MediaType;
import org.jboss.portal.common.util.MarkupInfo;
-import org.jboss.portal.server.ServerRequest;
import org.jboss.portal.theme.LayoutInfo;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
-import java.util.List;
-import java.util.Locale;
import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
/**
* A render context to render a context on a page. <p>A render context is scoped to a MarkupContainer (a region, or a
@@ -48,9 +47,6 @@
private PortalRenderSet renderSet;
/** . */
- private ServerRequest request;
-
- /** . */
private PageRenderContext pageRenderContext;
/** . */
@@ -60,53 +56,23 @@
private StringBuffer markup;
/** . */
- private ObjectRenderContext targetRenderContext;
-
- /** . */
private MarkupInfo markupInfo;
/** . */
private ArrayList stack;
- // initialize
- private void init(PortalLayout layout, ObjectRenderContext fragment, MarkupInfo markupInfo, PageRenderContext pageRenderContext, ServerRequest request)
- {
- String renderSetName = pageRenderContext.getProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
- PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(layout.getLayoutInfo(), markupInfo, renderSetName);
- if (renderSet == null)
- {
- throw new IllegalStateException("No RenderSet determined");
- }
+ /** . */
+ private Map attributes;
- //
- this.renderSet = renderSet;
- this.layout = layout;
- this.pageRenderContext = pageRenderContext;
- this.request = request;
- this.targetRenderContext = fragment;
- this.markupInfo = markupInfo;
- this.stack = new ArrayList(6);
- this.markup = new StringBuffer();
-
- //
- stack.add(pageRenderContext);
- }
-
- private RenderContext(PortalLayout layout, ObjectRenderContext markupContainer, MarkupInfo streamInfo, PageRenderContext result, ServerRequest request)
- {
- init(layout, markupContainer, streamInfo, result, request);
- }
-
/**
* Create a new render context for the provided result. <p>The result contains information about the markup container
* (page, region , window context) to render.</p>
*
* @param layout the layout that is used for this render context
* @param markupInfo information about the content type and encoding to use when writing the response
- * @param result the rendered result(s) from the portlet container (PageResult, RegionResult, WindowResult)
- * @param request the current server request
+ * @param pageRenderContext the rendered result(s) from the portlet container (PageResult, RegionResult, WindowResult)
*/
- public RenderContext(PortalLayout layout, MarkupInfo markupInfo, PageRenderContext result, ServerRequest request)
+ public RenderContext(PortalLayout layout, MarkupInfo markupInfo, PageRenderContext pageRenderContext)
{
if (layout == null)
{
@@ -116,98 +82,98 @@
{
throw new IllegalArgumentException("no stream info provided");
}
- if (result == null)
+ if (pageRenderContext == null)
{
throw new IllegalArgumentException("no result provided");
}
- if (request == null)
+
+ // Find a valid render set
+ String renderSetName = pageRenderContext.getProperty(ThemeConstants.PORTAL_PROP_RENDERSET);
+ if (renderSetName == null)
{
- throw new IllegalArgumentException("no request provided");
+ throw new IllegalArgumentException("No RenderSet determined");
}
+ PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(layout.getLayoutInfo(), markupInfo, renderSetName);
+ if (renderSet == null)
+ {
+ throw new IllegalArgumentException("No RenderSet determined for " + renderSetName);
+ }
- // context for the entire page
- init(layout, null, markupInfo, result, request);
- }
+ //
+ this.renderSet = renderSet;
+ this.layout = layout;
+ this.pageRenderContext = pageRenderContext;
+ this.markupInfo = markupInfo;
+ this.stack = new ArrayList(6);
+ this.markup = new StringBuffer();
+ this.attributes = new HashMap();
- /**
- * Copy constructor. <p>Get a render context for a region, based on the state of this render context, but with the
- * provided css id and orientation (which overwrite the values in the provided region)</p>
- */
- public RenderContext getContext(RegionRenderContext region)
- {
- return new RenderContext(this.layout, region, this.markupInfo, this.pageRenderContext, this.request);
+ //
+ this.stack.add(this.pageRenderContext);
}
- /**
- * copy constructor. <p>Get the render context for the provided window context, using the current context as a
- * template for layout, stream info,....</p>
- *
- * @param windowContext the window (context) to get the render context for
- * @return a render context that can render the markup for the provided window context
- */
- public RenderContext getContext(WindowRenderContext windowContext)
- {
- return new RenderContext(layout, windowContext, markupInfo, pageRenderContext, request);
- }
-
- /** @return a markup fragment */
public StringBuffer getMarkupFragment()
{
return markup;
}
- /** @return the content type */
public MediaType getContentType()
{
return markupInfo.getContentType();
}
- /** @return the encoding to use when writing to the output */
public String getCharset()
{
return markupInfo.getCharset();
}
- /** @return metadata about the layout used for this render context */
public LayoutInfo getLayoutInfo()
{
return layout.getLayoutInfo();
}
- /** @return the region renderer for the determined renderset of this context */
- public RegionRenderer getRegionRenderer()
+ public Object getAttribute(String attrName)
{
- return renderSet.getRegionRenderer();
+ if (attrName == null)
+ {
+ throw new IllegalArgumentException("No null attribute name");
+ }
+ return attributes.get(attrName);
}
- /**
- * Get the region renderer from the render set whose name was provided. <p>If no render set name was provided, this
- * method is identical to the no arg version</p>
- *
- * @param renderSetName the name of an alternative render set to get the region renderer from
- * @return a region renderer
- */
- public RegionRenderer getRegionRenderer(String renderSetName)
+ public void setAttribute(String attrName, Object attrValue)
{
- if (renderSetName == null)
+ if (attrName == null)
{
- return getRegionRenderer();
+ throw new IllegalArgumentException("No null attribute name");
}
-
- PortalRenderSet renderSet = layout.getServiceInfo().getRenderSet(renderSetName, markupInfo.getContentType());
-
- if (renderSet != null)
+ if (attrValue != null)
{
- return renderSet.getRegionRenderer();
+ attributes.put(attrName, attrValue);
}
+ else
+ {
+ attributes.remove(attrName);
+ }
+ }
+ public String getProperty(String propertyName)
+ {
+ for (int i = stack.size() - 1;i >= 0;i--)
+ {
+ ObjectRenderContext ctx = (ObjectRenderContext)stack.get(i);
+ String propertyValue = ctx.getProperty(propertyName);
+ if (propertyValue != null)
+ {
+ return propertyValue;
+ }
+ }
return null;
}
- /** @return the window renderer for the determined render set of this context */
- public WindowRenderer getWindowRenderer()
+ public RegionRenderer getRegionRenderer(RegionRenderContext result)
{
- return renderSet.getWindowRenderer();
+ return renderSet.getRegionRenderer();
}
/**
@@ -246,30 +212,9 @@
}
//
- return getWindowRenderer();
+ return renderSet.getWindowRenderer();
}
- public String getProperty(String propertyName)
- {
- for (int i = stack.size() - 1;i >= 0;i--)
- {
- ObjectRenderContext ctx = (ObjectRenderContext)stack.get(i);
- String propertyValue = ctx.getProperty(propertyName);
- if (propertyValue != null)
- {
- return propertyValue;
- }
- }
- return null;
- }
-
-
- /** @return a decoration renderer from the determined render set */
- public DecorationRenderer getDecorationRenderer()
- {
- return renderSet.getDecorationRenderer();
- }
-
/**
* Get the decoration renderer for the window that the provided window result is associated with. <p>If the window
* result contains a window property that points to a render set, that render set will be used to determine the
@@ -307,20 +252,10 @@
}
//
- return getDecorationRenderer();
+ return renderSet.getDecorationRenderer();
}
/**
- * Get the portlet renderer from the render set that was determined for this context.
- *
- * @return a portlet renderer
- */
- public PortletRenderer getPortletRenderer()
- {
- return renderSet.getPortletRenderer();
- }
-
- /**
* Get the portlet renderer for the render set defined in the window properties that were provided. <p>If the
* provided window result doesn't contain any window property that defines a render set name, the default render set
* that was determined for this context will be used to get the portlet renderer.</p>
@@ -358,36 +293,12 @@
}
//
- return getPortletRenderer();
+ return renderSet.getPortletRenderer();
}
- /** @return the names of all the regions as defined in the layout */
- public List getLayoutRegionNames()
- {
- return layout.getLayoutInfo().getRegionNames();
- }
-
- public Locale getLocale()
- {
- return request.getLocale();
- }
-
- public Locale[] getLocales()
- {
- return request.getLocales();
- }
-
- /**
- * Render this context and it's children (i.e. create the markup of this context and write it to the markup fragment
- * of this context) <p>Currently this context only knows how to render fragments of a page (i.e. region,window), not
- * the entire page.</p>
- *
- * @throws RenderException .
- * @see #getMarkupFragment
- */
public void render() throws RenderException
{
- render(targetRenderContext);
+ render(pageRenderContext);
}
@@ -407,7 +318,7 @@
else if (ctx instanceof RegionRenderContext)
{
RegionRenderContext rrc = (RegionRenderContext)ctx;
- RegionRenderer renderer = getRegionRenderer();
+ RegionRenderer renderer = getRegionRenderer(rrc);
//
renderer.renderHeader(this, rrc);
@@ -434,14 +345,4 @@
stack.remove(stack.size() - 1);
}
}
-
- public ServerRequest getRequest()
- {
- return request;
- }
-
- public void setRequest(ServerRequest request)
- {
- this.request = request;
- }
}
\ No newline at end of file
17 years, 1 month
JBoss Portal SVN: r6900 - in trunk/core-admin/src: main/org/jboss/portal/core/admin/ui/actions and 3 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-04-02 11:22:03 -0400 (Mon, 02 Apr 2007)
New Revision: 6900
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editProperties.xhtml
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
Log:
Ability to edit portal object properties, step 1
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-04-01 01:23:45 UTC (rev 6899)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-04-02 15:22:03 UTC (rev 6900)
@@ -38,6 +38,7 @@
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.portal.PortalObject;
@@ -127,7 +128,7 @@
private PortalObject selectedObject;
/** . */
- private List selectedProperties;
+ private PropertiesBean selectedProperties;
/** . */
private PortletInvoker portletDefinitionInvoker;
@@ -317,7 +318,7 @@
return selectedObject;
}
- public List getSelectedProperties()
+ public PropertiesBean getSelectedProperties()
{
return selectedProperties;
}
@@ -497,11 +498,12 @@
if (selectedProperties == null)
{
PortalObject object = getSelectedObject();
- List properties = new ArrayList();
+ PropertiesBean properties = new PropertiesBean(true);
for (Iterator i = object.getDeclaredProperties().entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry)i.next();
- properties.add(new String[]{(String)entry.getKey(), (String)entry.getValue()});
+ PropertyInfo info = new PropertyInfo(object, (String)entry.getKey(), false);
+ properties.addEntry(info, (String)entry.getValue());
}
selectedProperties = properties;
}
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java 2007-04-02 15:22:03 UTC (rev 6900)
@@ -0,0 +1,135 @@
+/******************************************************************************
+ * 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.core.admin.ui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertiesBean
+{
+
+ /** . */
+ List entries;
+
+ /** . */
+ int selectedIndex;
+
+ /** . */
+ private boolean mutable;
+
+ public PropertiesBean(boolean mutable)
+ {
+ this.entries = new ArrayList();
+ this.selectedIndex = -1;
+ this.mutable = mutable;
+ }
+
+ public boolean isMutable()
+ {
+ return mutable;
+ }
+
+ public int getSelectedIndex()
+ {
+ return selectedIndex;
+ }
+
+ public void setSelectedIndex(int selectedIndex)
+ {
+ if (selectedIndex < 0 || selectedIndex >= entries.size())
+ {
+ throw new IllegalArgumentException();
+ }
+ this.selectedIndex = selectedIndex;
+ }
+
+ public void unselectEntry()
+ {
+ selectedIndex = -1;
+ }
+
+ public PreferenceBean getSelectedEntry()
+ {
+ if (selectedIndex < 0 || selectedIndex >= entries.size())
+ {
+ return null;
+ }
+ return (PreferenceBean)entries.get(selectedIndex);
+ }
+
+ public void addEntry(PropertyInfo info, String value)
+ {
+ if (!mutable)
+ {
+ throw new IllegalStateException("Cannot add non mutable entry to a mutable preferences bean");
+ }
+
+ //
+ addEntry(new PropertyBean(info, value));
+ }
+
+ private void addEntry(PropertyBean pref)
+ {
+ if (pref.container != null)
+ {
+ throw new IllegalArgumentException("Already contained somewhere");
+ }
+ pref.container = this;
+ entries.add(pref);
+ Collections.sort(entries);
+ }
+
+ public void addEntry()
+ {
+ PropertyBean bean = (PropertyBean)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("property");
+ System.out.println(bean.getName());
+/*
+ String s = event.getComponent().getId();
+ int index = Integer.parseInt(s.substring(4));
+ List list = new ArrayList(value.asStringList());
+ list.remove(index);
+ String[] strings = (String[])list.toArray(new String[list.size()]);
+ value = new StringValue(strings);
+ stale = true;
+ */
+ }
+
+ public List getEntries()
+ {
+ return Collections.unmodifiableList(entries);
+ }
+
+ public int getSize()
+ {
+ return entries.size();
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java 2007-04-02 15:22:03 UTC (rev 6900)
@@ -0,0 +1,212 @@
+/******************************************************************************
+ * 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.core.admin.ui;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.core.model.portal.PortalObject;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertyBean implements Comparable
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private boolean readOnly;
+
+ /** . */
+ private LocalizedString displayName;
+
+ /** . */
+ private String value;
+
+ /** . */
+ PropertiesBean container;
+
+ private PortalObject portalObject;
+
+ public PropertyBean()
+ {
+ name="toto";
+ value="foo";
+ }
+
+ public PropertyBean(PropertyInfo info, String value)
+ {
+ this.name = info.getName();
+ this.portalObject = info.getPortalObject();
+ this.readOnly = info.isReadOnly();
+ this.displayName = info.getDisplayName();
+ this.value = value;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly)
+ {
+ this.readOnly = readOnly;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName(LocalizedString displayName)
+ {
+ this.displayName = displayName;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ portalObject.setDeclaredProperty(name, value);
+ }
+
+
+ /*
+ public List getIndices()
+ {
+ List list = new ArrayList(value.size());
+ for (int i = 0;i < value.size();i++)
+ {
+ list.add("index_" + i);
+ }
+ return list;
+ }
+
+ public String getLine()
+ {
+ return line;
+ }
+
+ public void setLine(String line)
+ {
+ this.line = line;
+ }
+ */
+
+ public void select()
+ {
+ if (container == null)
+ {
+ throw new IllegalStateException("Not attached to a container");
+ }
+ container.selectedIndex = container.entries.indexOf(this);
+ }
+
+ /*
+ public void deleteLine(ActionEvent event)
+ {
+ String s = event.getComponent().getId();
+ int index = Integer.parseInt(s.substring(4));
+ List list = new ArrayList(value.asStringList());
+ list.remove(index);
+ String[] strings = (String[])list.toArray(new String[list.size()]);
+ value = new StringValue(strings);
+ stale = true;
+ }
+
+ public void appendLine()
+ {
+ List list = new ArrayList(value.asStringList());
+ list.add(line);
+ String[] strings = (String[])list.toArray(new String[list.size()]);
+ value = new StringValue(strings);
+ stale = true;
+ line = null;
+ }
+
+
+ public Class getType(Object propertyName) throws IllegalArgumentException
+ {
+ if (propertyName instanceof String)
+ {
+ String s = (String)propertyName;
+ if (s.startsWith("index_"))
+ {
+ return String.class;
+ }
+ }
+ return null;
+ }
+ */
+
+ /*
+ public PropertyValue getValue(Object propertyName) throws IllegalArgumentException
+ {
+ if (propertyName instanceof String)
+ {
+ String s = (String)propertyName;
+ if (s.startsWith("index_"))
+ {
+ int index = Integer.parseInt(s.substring(6));
+ return new PropertyValue(value.asStringList().get(index));
+ }
+ }
+ return null;
+ }
+
+ public boolean setValue(Object propertyName, Object value) throws IllegalArgumentException
+ {
+ if (propertyName instanceof String)
+ {
+ String s = (String)propertyName;
+ if (s.startsWith("index_"))
+ {
+ String[] tmp = this.value.asStringArray();
+ int index = Integer.parseInt(s.substring(6));
+ tmp[index] = (String)value;
+ this.value = new StringValue(tmp);
+ stale = true;
+ return true;
+ }
+ }
+ return false;
+ }
+*/
+ public int compareTo(Object o)
+ {
+ PropertyBean that = (PropertyBean)o;
+ return name.compareTo(that.name);
+ }
+
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyInfo.java 2007-04-02 15:22:03 UTC (rev 6900)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * 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.core.admin.ui;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.core.model.portal.PortalObject;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertyInfo
+{
+ /** . */
+ private String name;
+
+ /** . */
+ private boolean readOnly;
+
+ /** . */
+ private LocalizedString displayName;
+
+ private PortalObject portalObject;
+
+ public PropertyInfo(PortalObject portalObject, String name, boolean readOnly)
+ {
+ this.name = name;
+ this.readOnly = readOnly;
+ this.portalObject = portalObject;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName(LocalizedString displayName)
+ {
+ this.displayName = displayName;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ public void setReadOnly(boolean readOnly)
+ {
+ this.readOnly = readOnly;
+ }
+
+ public PortalObject getPortalObject()
+ {
+ return portalObject;
+ }
+
+}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2007-04-01 01:23:45 UTC (rev 6899)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2007-04-02 15:22:03 UTC (rev 6900)
@@ -22,7 +22,10 @@
******************************************************************************/
package org.jboss.portal.core.admin.ui.actions;
+import java.util.Map;
+
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
+import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
@@ -101,6 +104,9 @@
public void removeProperty()
{
+ Map pmap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ String name = (String)pmap.get("name");
+ ((PortalObjectImpl)getPortalObjectManager().getSelectedObject()).getDeclaredPropertyMap().remove(name);
}
public void updateProperty()
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-04-01 01:23:45 UTC (rev 6899)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-04-02 15:22:03 UTC (rev 6900)
@@ -304,6 +304,10 @@
<to-view-id>/WEB-INF/jsf/editPageSecurity.xhtml</to-view-id>
</navigation-case>
<navigation-case>
+ <from-outcome>editProperties</from-outcome>
+ <to-view-id>/WEB-INF/jsf/editProperties.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
<from-outcome>editPageTheme</from-outcome>
<to-view-id>/WEB-INF/jsf/editPageTheme.xhtml</to-view-id>
</navigation-case>
Added: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/editProperties.xhtml 2007-04-02 15:22:03 UTC (rev 6900)
@@ -0,0 +1,62 @@
+<div
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+ <h:form>
+ <table width="100%">
+ <thead class="portlet-section-header" style="text-align:left;">
+ <tr>
+ <th>Name</th>
+ <th>Value</th>
+ <th>Delete</th>
+ </tr>
+ </thead>
+ <tbody>
+ <c:forEach items="#{properties.entries}" var="prop" varStatus="status">
+ <tr class="#{status.index % 2 == 0 ? 'portlet-section-body' : 'portlet-section-alternate'}">
+ <td>
+ <h:outputText>#{prop.name}</h:outputText>
+ </td>
+ <td>
+ <h:inputText value="#{prop.value}"/>
+ </td>
+ <td>
+ <h:commandLink action="#{propertyAction.removeProperty}">
+ <h:outputText>Delete</h:outputText>
+ <f:param name="name" value="#{prop.name}"/>
+ </h:commandLink>
+ </td>
+ </tr>
+ </c:forEach>
+ </tbody>
+ </table>
+ <h:commandButton value="Update" styleClass="portlet-form-button"/>
+ </h:form>
+
+ <h:form>
+ <table width="100%">
+ <thead class="portlet-section-header" style="text-align:left;">
+ <tr>
+ <th>Property name</th>
+ <th>Property value</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr class="#{status.index % 2 == 0 ? 'portlet-section-body' : 'portlet-section-alternate'}">
+ <td>
+ <h:inputText value="#{propertyAction.selectedProperty}"
+ validator="#{propertyAction.validatePropertyName}" />
+ </td>
+ <td>
+ <h:inputText value="#{propertyAction.propertyValue}"/>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <h:commandButton value="Add property" styleClass="portlet-form-button" action="#{propertyAction.updateProperty}"/>
+ </h:form>
+
+</div>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml 2007-04-01 01:23:45 UTC (rev 6899)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPage.xhtml 2007-04-02 15:22:03 UTC (rev 6900)
@@ -15,7 +15,10 @@
</h:commandLink> | </h:panelGroup><h:commandLink action="editPageSecurity" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Security"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
- </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
+ </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
+ <h:outputText value="Properties"/>
+ <f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
+ </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Theme"/>
<f:param name="id" value="#{portalobjectmgr.selectedObject.id}"/>
</h:commandLink> | <h:panelGroup rendered="#{!((portalobjectmgr.selectedObject.type == 1) and ((portalobjectmgr.selectedObject.name == 'admin') or (portalobjectmgr.selectedObject.name == 'template') or (portalobjectmgr.selectedObject.name == 'default')))}"><h:commandLink action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
Added: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editProperties.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editProperties.xhtml (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editProperties.xhtml 2007-04-02 15:22:03 UTC (rev 6900)
@@ -0,0 +1,18 @@
+<div
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html">
+
+ <ui:composition template="objectTemplate.xhtml">
+
+ <ui:define name="content">
+
+ <ui:include src="common/editProperties.xhtml">
+ <ui:param name="properties" value="#{portalobjectmgr.selectedProperties}"/>
+ </ui:include>
+
+ </ui:define>
+
+ </ui:composition>
+</div>
\ No newline at end of file
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-04-01 01:23:45 UTC (rev 6899)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/objectNavigation.xhtml 2007-04-02 15:22:03 UTC (rev 6900)
@@ -30,6 +30,9 @@
<h:commandLink action="editPortalSecurity" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Security"/>
<f:param name="id" value="#{object.id}"/>
+ </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
+ <h:outputText value="Properties"/>
+ <f:param name="id" value="#{object.id}"/>
</h:commandLink> | <h:commandLink action="editPortalTheme"
actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Theme"/>
@@ -71,7 +74,10 @@
actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Security"/>
<f:param name="id" value="#{object.id}"/>
- </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
+ </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
+ <h:outputText value="Properties"/>
+ <f:param name="id" value="#{object.id}"/>
+ </h:commandLink> | <h:commandLink action="editPageTheme" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Theme"/>
<f:param name="id" value="#{object.id}"/>
</h:commandLink> | <h:commandLink action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
@@ -107,6 +113,9 @@
<h:commandLink action="editWindowTheme" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Theme"/>
<f:param name="id" value="#{object.id}"/>
+ </h:commandLink> | <h:commandLink action="editProperties" actionListener="#{portalobjectmgr.selectObject}">
+ <h:outputText value="Properties"/>
+ <f:param name="id" value="#{object.id}"/>
</h:commandLink> | <h:commandLink action="renameObject" actionListener="#{portalobjectmgr.selectObject}">
<h:outputText value="Rename"/>
<f:param name="id" value="#{object.id}"/>
17 years, 1 month
JBoss Portal SVN: r6899 - in trunk: theme/src/bin/portal-ajax-war/js/portal and 1 other directory.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-31 21:23:45 -0400 (Sat, 31 Mar 2007)
New Revision: 6899
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
Log:
- preliminary work to handle FORM in ppr
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-01 00:41:10 UTC (rev 6898)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-01 01:23:45 UTC (rev 6899)
@@ -33,6 +33,7 @@
import org.jboss.portal.core.model.portal.command.PortalObjectCommand;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.model.portal.command.response.UpdateWindowMarkupResponse;
+import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.Page;
@@ -56,6 +57,8 @@
import org.jboss.portal.common.util.MarkupInfo;
import org.jboss.portal.WindowState;
import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;
@@ -119,8 +122,18 @@
public HandlerResponse handleResponse(ControllerContext ctx, ControllerCommand cmd, Object response) throws IOException, ServletException, ServerException
{
- if (response instanceof UpdateWindowMarkupResponse)
+ if (response instanceof PortletWindowResponse)
{
+ PortletWindowResponse pwr = (PortletWindowResponse)response;
+ PortletInvocationResponse pir = pwr.getResult();
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse rr = (RenderResponse)pir;
+ }
+
+ }
+ else if (response instanceof UpdateWindowMarkupResponse)
+ {
UpdateWindowMarkupResponse updateMarkup = (UpdateWindowMarkupResponse)response;
// Figure out if we need a full refresh or not
@@ -143,7 +156,6 @@
// Obtain page and portal
final Window window = (Window)portalObjectContainer.getObject(pocmd.getTargetId());
Page page = (Page)window.getParent();
- Portal portal = page.getPortal();
//
if (fullRefresh)
@@ -154,6 +166,7 @@
UpdatePageResponse dresp = new UpdatePageResponse(url);
AjaxResponse aresp = new AjaxResponse(dresp);
aresp.sendResponse(invocation.getServerContext());
+ return null;
}
else
{
@@ -266,6 +279,7 @@
DynaResponse dresp = new UpdateMarkupResponse(renderCtx.getMarkupFragment().toString());
AjaxResponse aresp = new AjaxResponse(dresp);
aresp.sendResponse(invocation.getServerContext());
+ return null;
}
catch (RenderException e)
{
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-01 00:41:10 UTC (rev 6898)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-01 01:23:45 UTC (rev 6899)
@@ -46,19 +46,63 @@
// We found the window
if (container != null) {
+
+ var form = source.nodeName == "FORM";
+ var link = !form & source.nodeName == "A";
+
+ var url;
+ var body;
+ var method;
+
+ if (source.nodeName == "A")
+ {
+ url = source.href;
+ method = "get";
+ body = "";
+ }
+// else if (source.nodeName == "INPUT" && source.type == "submit")
+// {
+// // Find enclosing form
+// var current = source.parentNode;
+// while (current.nodeName != 'FORM' && current.nodeName != 'BODY') {
+// current = current.parentNode;
+// }
+//
+// // Check we have a form and use it
+// if (current.nodeName == 'FORM') {
+//
+// //
+// url = current.action;
+//
+// // Get body if needed
+// if (current.method.toLowerCase() == "post") {
+// body = Form.serialize(current);
+// method = "post";
+// }
+// else
+// {
+// body = "";
+// method = "get";
+// }
+// }
+// }
+
// Handle links here
- if (source.nodeName == "A") {
- var url = source.href;
+ if (url != null) {
+
var parameters = "";
var pos = url.indexOf("?");
if (pos != -1) {
parameters = url.substring(pos + 1);
url = url.substring(0, pos);
}
+
+ //
var options = {
parameters:parameters,
asynchronous:true,
- method:"get",
+ method: method,
+ postBody: body,
requestHeaders:["ajax","true"],
onSuccess: function(t)
{
@@ -81,6 +125,13 @@
}
};
+ // Add the form post body
+ // todo : detect file upload
+ if (form)
+ {
+ options.postBody = Form.serialize(source);
+ }
+
//
Event.stop(event);
new Ajax.Request(url, options);
17 years, 1 month
JBoss Portal SVN: r6898 - in trunk: core/src/main/org/jboss/portal/core/model/portal/command and 3 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-31 20:41:10 -0400 (Sat, 31 Mar 2007)
New Revision: 6898
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java
trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
Log:
- better handling of maximized mode
- better handling of div decoration modes and window states actions (use <span><a/></span> instead of <a><div/></a>)
Modified: trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-03-31 17:46:47 UTC (rev 6897)
+++ trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxController.java 2007-04-01 00:41:10 UTC (rev 6898)
@@ -58,7 +58,6 @@
import org.jboss.portal.Mode;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Collection;
@@ -123,13 +122,18 @@
if (response instanceof UpdateWindowMarkupResponse)
{
UpdateWindowMarkupResponse updateMarkup = (UpdateWindowMarkupResponse)response;
- RenderWindowCommand rwc = new RenderWindowCommand(updateMarkup.getWindowId());
- return new CommandForward(rwc, null);
- }
- else if (response instanceof WindowResult)
- {
- final WindowResult windowResult = (WindowResult)response;
+ // Figure out if we need a full refresh or not
+ boolean fullRefresh;
+ if (WindowState.MAXIMIZED.equals(updateMarkup.getNewWindowState()))
+ {
+ fullRefresh = !WindowState.MAXIMIZED.equals(updateMarkup.getOldWindowState());
+ }
+ else
+ {
+ fullRefresh = WindowState.MAXIMIZED.equals(updateMarkup.getOldWindowState());
+ }
+
// We make an assumption here, the window result should carry somehow the window id
PortalObjectCommand pocmd = (PortalObjectCommand)cmd;
@@ -142,7 +146,7 @@
Portal portal = page.getPortal();
//
- if (windowResult.getWindowState().equals(WindowState.MAXIMIZED))
+ if (fullRefresh)
{
// For now we handle a full page refresh
RenderPageCommand rpc = new RenderPageCommand(page.getId());
@@ -153,102 +157,120 @@
}
else
{
- // Call to the theme framework
- PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
- PageRenderContext prc = new PageRenderContextImpl(res);
+ RenderWindowCommand rwc = new RenderWindowCommand(updateMarkup.getWindowId());
+ return new CommandForward(rwc, null);
+ }
+ }
+ else if (response instanceof WindowResult)
+ {
+ final WindowResult windowResult = (WindowResult)response;
- // Obtain layout
- LayoutService layoutService = getPageService().getLayoutService();
- PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+ // We make an assumption here, the window result should carry somehow the window id
+ PortalObjectCommand pocmd = (PortalObjectCommand)cmd;
- //
- WindowRenderContext wrc = new WindowRenderContext()
+ //
+ ServerInvocation invocation = ctx.getServerInvocation();
+
+ // Obtain page and portal
+ final Window window = (Window)portalObjectContainer.getObject(pocmd.getTargetId());
+ Page page = (Page)window.getParent();
+ Portal portal = page.getPortal();
+
+ // Call to the theme framework
+ PageResult res = new PageResult(page.getName(), page.getProperties(), portal.getProperties());
+ PageRenderContext prc = new PageRenderContextImpl(res);
+
+ // Obtain layout
+ LayoutService layoutService = getPageService().getLayoutService();
+ PortalLayout layout = RenderPageCommand.getLayout(layoutService, page);
+
+ //
+ WindowRenderContext wrc = new WindowRenderContext()
+ {
+ public String getId()
{
- public String getId()
- {
- return window.getId().toString();
- }
+ return window.getId().toString();
+ }
- public int getOrder()
- {
- return 0;
- }
+ public int getOrder()
+ {
+ return 0;
+ }
- public WindowState getWindowState()
- {
- return windowResult.getWindowState();
- }
+ public WindowState getWindowState()
+ {
+ return windowResult.getWindowState();
+ }
- public Mode getMode()
- {
- return windowResult.getMode();
- }
+ public Mode getMode()
+ {
+ return windowResult.getMode();
+ }
- public DecorationRenderContext getDecoration()
+ public DecorationRenderContext getDecoration()
+ {
+ return new DecorationRenderContext()
{
- return new DecorationRenderContext()
+ public String getId()
{
- public String getId()
- {
- return window.getId().toString();
- }
+ return window.getId().toString();
+ }
- public String getTitle()
- {
- return windowResult.getTitle();
+ public String getTitle()
+ {
+ return windowResult.getTitle();
- }
+ }
- public Collection getTriggerableActions(String familyName)
- {
- return windowResult.getTriggerableActions(familyName);
- }
+ public Collection getTriggerableActions(String familyName)
+ {
+ return windowResult.getTriggerableActions(familyName);
+ }
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
- }
+ public String getProperty(String name)
+ {
+ return (String)windowResult.getWindowProperties().get(name);
+ }
+ };
+ }
- public PortletRenderContext getPortlet()
+ public PortletRenderContext getPortlet()
+ {
+ return new PortletRenderContext()
{
- return new PortletRenderContext()
+ public String getMarkup()
{
- public String getMarkup()
- {
- return windowResult.getContent();
- }
+ return windowResult.getContent();
+ }
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
- }
+ public String getProperty(String name)
+ {
+ return (String)windowResult.getWindowProperties().get(name);
+ }
+ };
+ }
- public String getProperty(String name)
- {
- return (String)windowResult.getWindowProperties().get(name);
- }
- };
+ public String getProperty(String name)
+ {
+ return (String)windowResult.getWindowProperties().get(name);
+ }
+ };
+ //
+ RenderContext renderCtx = new RenderContext(layout, (MarkupInfo)invocation.getResponse().getContentInfo(), prc, invocation.getRequest());
+ try
+ {
+ renderCtx.render(wrc);
+
//
- RenderContext renderCtx = new RenderContext(layout, (MarkupInfo)invocation.getResponse().getContentInfo(), prc, invocation.getRequest());
- try
- {
- renderCtx.render(wrc);
-
- //
- DynaResponse dresp = new UpdateMarkupResponse(renderCtx.getMarkupFragment().toString());
- AjaxResponse aresp = new AjaxResponse(dresp);
- aresp.sendResponse(invocation.getServerContext());
- }
- catch (RenderException e)
- {
- e.printStackTrace();
- }
+ DynaResponse dresp = new UpdateMarkupResponse(renderCtx.getMarkupFragment().toString());
+ AjaxResponse aresp = new AjaxResponse(dresp);
+ aresp.sendResponse(invocation.getServerContext());
}
+ catch (RenderException e)
+ {
+ e.printStackTrace();
+ }
}
else
{
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java 2007-03-31 17:46:47 UTC (rev 6897)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/InvokePortletWindowRenderCommand.java 2007-04-01 00:41:10 UTC (rev 6898)
@@ -89,27 +89,41 @@
ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId, navigationalState);
}
+ //
+ WindowState oldWS = null;
+ Mode oldMode = null;
+
// Update the window nav state
- WindowNavigationalState windowNavState = (WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window");
- if (windowNavState == null)
+ WindowNavigationalState windowNS = (WindowNavigationalState)ctx.getAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window");
+ if (windowNS == null)
{
- windowNavState = new WindowNavigationalState();
- ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window", windowNavState);
+ windowNS = new WindowNavigationalState();
+ ctx.setAttribute(NAVIGATIONAL_STATE_SCOPE, windowId + "_window", windowNS);
}
+ else
+ {
+ oldWS = windowNS.getWindowState();
+ oldMode = windowNS.getMode();
+ }
//
if (mode != null)
{
- windowNavState.setMode(mode);
+ windowNS.setMode(mode);
}
//
if (windowState != null)
{
- windowNavState.setWindowState(windowState);
+ windowNS.setWindowState(windowState);
}
//
- return new UpdateWindowMarkupResponse(windowId);
+ return new UpdateWindowMarkupResponse(
+ windowId,
+ oldWS,
+ windowNS.getWindowState(),
+ oldMode,
+ windowNS.getMode());
}
}
\ No newline at end of file
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java 2007-03-31 17:46:47 UTC (rev 6897)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/response/UpdateWindowMarkupResponse.java 2007-04-01 00:41:10 UTC (rev 6898)
@@ -23,6 +23,8 @@
package org.jboss.portal.core.model.portal.command.response;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -32,19 +34,60 @@
{
/** . */
- private PortalObjectId windowId;
+ private final PortalObjectId windowId;
- public UpdateWindowMarkupResponse(PortalObjectId windowId)
+ /** If not null indicate the previous window state. */
+ private final WindowState oldWindowState;
+
+ /** Indicate the current window state. */
+ private final WindowState newWindowState;
+
+ /** If not null indicate the previous mode. */
+ private final Mode oldMode;
+
+ /** Indicate the current mode. */
+ private final Mode newMode;
+
+ public UpdateWindowMarkupResponse(
+ PortalObjectId windowId,
+ WindowState oldWindowState,
+ WindowState newWindowState,
+ Mode oldMode,
+ Mode newMode)
{
if (windowId == null)
{
throw new IllegalArgumentException();
}
this.windowId = windowId;
+ this.oldWindowState = oldWindowState;
+ this.newWindowState = newWindowState;
+ this.oldMode = oldMode;
+ this.newMode = newMode;
}
public PortalObjectId getWindowId()
{
return windowId;
}
+
+ public WindowState getOldWindowState()
+ {
+ return oldWindowState;
+ }
+
+ public WindowState getNewWindowState()
+ {
+ return newWindowState;
+ }
+
+ public Mode getOldMode()
+ {
+ return oldMode;
+ }
+
+ public Mode getNewMode()
+ {
+ return newMode;
+ }
}
Modified: trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js
===================================================================
--- trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-03-31 17:46:47 UTC (rev 6897)
+++ trunk/theme/src/bin/portal-ajax-war/js/portal/dyna.js 2007-04-01 00:41:10 UTC (rev 6898)
@@ -67,12 +67,16 @@
if (resp.type == "update_markup")
{
var markup = resp.markup;
- Element.replace(container, markup);
+
+ // Remove the div
+ markup = markup.substring(31, markup.length - 6);
+
+ //
+ container.innerHTML = markup;
}
else if (resp.type == "update_page")
{
- var location = resp.location;
- document.location = location;
+ document.location = resp.location;
}
}
};
@@ -126,9 +130,9 @@
snapshot();
// Find the dyna portlets
- var portlets_on_page = document.getElementsByClassName("dyna-portlet");
+ var portlets_on_page = document.getElementsByClassName("dyna-window");
- // Add listener for teh dyna portlets
+ // Add listener for the dyna windows
for(var i = 0;i < portlets_on_page.length;i++) {
var portlet = portlets_on_page[i];
Event.observe(portlet, "click", bilto);
Modified: trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2007-03-31 17:46:47 UTC (rev 6897)
+++ trunk/theme/src/main/org/jboss/portal/theme/impl/render/div/DivDecorationRenderer.java 2007-04-01 00:41:10 UTC (rev 6898)
@@ -61,10 +61,11 @@
private static void renderTitle(RenderContext ctx, DecorationRenderContext drc)
{
- ctx.getMarkupFragment().append("<div class=\"portlet-titlebar-decoration\">");
- ctx.getMarkupFragment().append("<span class=\"portlet-titlebar-title\">");
- ctx.getMarkupFragment().append(drc.getTitle());
- ctx.getMarkupFragment().append("</span></div>");
+ StringBuffer out = ctx.getMarkupFragment();
+ out.append("<div class=\"portlet-titlebar-decoration\">");
+ out.append("<span class=\"portlet-titlebar-title\">");
+ out.append(drc.getTitle());
+ out.append("</span></div>");
}
private static void renderModeAndStateLinks(RenderContext ctx, DecorationRenderContext drc, String selector)
@@ -87,9 +88,8 @@
WindowResult.Action action = (WindowResult.Action)i.next();
if (action.isEnabled())
{
- ctx.getMarkupFragment().append("<div class=\"portlet-mode-").append(action.getName());
- ctx.getMarkupFragment().append("\" onClick=\"location.href='").append(action.getURL()).append("';\" title=\"");
- ctx.getMarkupFragment().append(action.getName()).append("\"></div>");
+ StringBuffer out = ctx.getMarkupFragment();
+ out.append("<span title=\"").append(action.getName()).append("\"><a class=\"portlet-mode-").append(action.getName()).append("\" href=\"").append(action.getURL()).append("\"> </a></span>");
}
}
}
17 years, 1 month