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>");
}
}
}