Author: julien(a)jboss.com
Date: 2006-11-28 02:51:34 -0500 (Tue, 28 Nov 2006)
New Revision: 5732
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java
trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java
Log:
- disabled ajax by default
- enable ajax only on dashboard
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 2006-11-28
06:43:48 UTC (rev 5731)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-11-28
07:51:34 UTC (rev 5732)
@@ -96,6 +96,8 @@
if (cmd instanceof RenderPageCommand)
{
RenderPageCommand rpc = (RenderPageCommand)cmd;
+
+ //
StringBuffer tabbedNav = injectTabbedNav(rpc);
if (tabbedNav != null)
{
@@ -110,7 +112,7 @@
//
Region region =
rendition.getPageResult().getRegion("navigation");
- region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_DISABLED,
"true");
+ region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED,
"false");
}
}
@@ -129,7 +131,7 @@
//
Region region =
rendition.getPageResult().getRegion("dashboardnav");
- region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_DISABLED,
"true");
+ region.setProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED,
"false");
}
}
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 2006-11-28
06:43:48 UTC (rev 5731)
+++
trunk/core/src/main/org/jboss/portal/core/controller/ajax/AjaxInterceptor.java 2006-11-28
07:51:34 UTC (rev 5732)
@@ -26,6 +26,7 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
import org.jboss.portal.theme.PageRendition;
import org.jboss.portal.theme.ThemeConstants;
@@ -43,42 +44,38 @@
{
Object response = cmd.invokeNext();
- //
- if (cmd instanceof RenderPageCommand)
+ // Configure ajax if needed
+ if (response != null && cmd instanceof RenderPageCommand)
{
RenderPageCommand rpc = (RenderPageCommand)cmd;
PageRendition rendition = (PageRendition)response;
- // Configure ajax
- if (rendition != null)
- {
- Map pageProps = rendition.getPageResult().getPageProperties();
+ Map pageProps = rendition.getPageResult().getPageProperties();
- //
- pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
+ //
+ pageProps.put(ThemeConstants.PORTAL_AJAX_JAVASCRIPT_BASE,
"/portal-ajax");
- // If user is logged in and is not on dashboard we disable ajax
- if
(cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
!= null)
+ // If user is logged in and is on dashboard we enable ajax
+ if
(cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser()
!= null)
+ {
+ if (rpc.isDashboard())
{
- if (rpc.isDashboard() == false)
- {
- pageProps.put(ThemeConstants.PORTAL_AJAX_OBJECT_DISABLED,
"true");
- }
+ pageProps.put(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED,
"true");
}
+ }
- // Compute the url for the ajax servlet
- HttpServletRequest req =
cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest();
- StringBuffer url = new StringBuffer();
- url.append(req.getScheme()).append("://");
- url.append(req.getServerName());
- if (("http".equals(req.getScheme()) && req.getServerPort()
!= 80) || ("https".equals(req.getScheme()) && req.getServerPort() !=
443))
- {
- url.append(':').append(req.getServerPort());
- }
- url.append(req.getContextPath()).append("/ajax");
-
- pageProps.put(ThemeConstants.PORTAL_AJAX_REMOTE_URL, url.toString());
+ // Compute the url for the ajax servlet
+ HttpServletRequest req =
cmd.getControllerContext().getServerInvocation().getServerContext().getClientRequest();
+ StringBuffer url = new StringBuffer();
+ url.append(req.getScheme()).append("://");
+ url.append(req.getServerName());
+ if (("http".equals(req.getScheme()) && req.getServerPort() !=
80) || ("https".equals(req.getScheme()) && req.getServerPort() != 443))
+ {
+ url.append(':').append(req.getServerPort());
}
+ url.append(req.getContextPath()).append("/ajax");
+
+ pageProps.put(ThemeConstants.PORTAL_AJAX_REMOTE_URL, url.toString());
}
//
Modified:
trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2006-11-28
06:43:48 UTC (rev 5731)
+++
trunk/core/src/main/org/jboss/portal/core/model/instance/command/InvokePortletInstanceRenderCommand.java 2006-11-28
07:51:34 UTC (rev 5732)
@@ -96,7 +96,6 @@
LayoutService ls = ps.getLayoutService();
PortalLayout layout = ls.getLayout("generic", true);
Map pageProperties = new HashMap();
- pageProperties.put(ThemeConstants.PORTAL_AJAX_OBJECT_DISABLED,
"true");
Map portalProperties = new HashMap();
portalProperties.put("theme.renderSetId", "divRenderer");
portalProperties.put("theme.id", "renaissance");
Modified: trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java
===================================================================
--- trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2006-11-28 06:43:48
UTC (rev 5731)
+++ trunk/theme/src/main/org/jboss/portal/theme/ThemeConstants.java 2006-11-28 07:51:34
UTC (rev 5732)
@@ -99,5 +99,5 @@
/**
*
*/
- public static final String PORTAL_AJAX_OBJECT_DISABLED =
"theme.ajax.object_disabled";
+ public static final String PORTAL_AJAX_OBJECT_ENABLED =
"theme.ajax.object_enabled";
}
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 2006-11-28
06:43:48 UTC (rev 5731)
+++
trunk/theme/src/main/org/jboss/portal/theme/impl/render/dynamic/DynaRegionRenderer.java 2006-11-28
07:51:34 UTC (rev 5732)
@@ -50,11 +50,11 @@
private RegionRenderer delegate;
- private static final ThreadLocal disabledLocal = new ThreadLocal();
+ private static final ThreadLocal enabledLocal = new ThreadLocal();
public static boolean isEnabled()
{
- return Boolean.TRUE.equals(disabledLocal.get()) == false;
+ return Boolean.TRUE == enabledLocal.get();
}
public DynaRegionRenderer(RegionRenderer regionRenderer) throws
InstantiationException,
@@ -76,163 +76,167 @@
String remoteURL = (String)pageProps.get(ThemeConstants.PORTAL_AJAX_REMOTE_URL);
//
- Boolean disabled = null;
- if
("true".equals(region.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_DISABLED)))
- {
- disabled = Boolean.TRUE;
- }
- else if
("true".equals(renderContext.getPageProperties().get(ThemeConstants.PORTAL_AJAX_OBJECT_DISABLED)))
- {
- disabled = Boolean.TRUE;
- }
+ Object onPage =
renderContext.getPageProperties().get(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
+ boolean pageEnabled = onPage != null && "true".equals(onPage);
- // Handle special ajax region here
- if ("AJAXFooter".equals(region.getId()))
+ //
+ boolean regionEnabled = false;
+ if (pageEnabled)
{
- disabled = Boolean.TRUE;
+ // Handle special ajax region here
+ if ("AJAXFooter".equals(region.getId()))
+ {
+ markup.append("<script>\n");
+ markup.append(
+ "\n" +
+ "var toto = new Array();\n" +
+ "for(region in regions_on_page) {\n" +
+ " toto.push(region);\n" +
+ "}\n" +
+ "for(region in regions_on_page) {\n" +
+ "Sortable.create(region,
{dropOnEmpty:true,handle:'handle',tag:'div',containment:toto,constraint:false,
ghosting: false,\n" +
+ " onChange: function(el)\n" +
+ " {\n" +
+ " },\n" +
+ " onUpdate: function (el)\n" +
+ " {\n" +
+ " }\n" +
+ "});\n" +
+ "}\n");
- markup.append("<script>\n");
- markup.append(
- "\n" +
- "var toto = new Array();\n" +
- "for(region in regions_on_page) {\n" +
- " toto.push(region);\n" +
- "}\n" +
- "for(region in regions_on_page) {\n" +
- "Sortable.create(region,
{dropOnEmpty:true,handle:'handle',tag:'div',containment:toto,constraint:false,
ghosting: false,\n" +
- " onChange: function(el)\n" +
- " {\n" +
- " },\n" +
- " onUpdate: function (el)\n" +
- " {\n" +
- " }\n" +
- "});\n" +
- "}\n");
+ //
+ markup.append("Draggables.addObserver(new
WindowMoveObserver());\n");
- //
- markup.append("Draggables.addObserver(new WindowMoveObserver());\n");
+ //
+ markup.append("snapshot();\n");
- //
- markup.append("snapshot();\n");
+ //
+ markup.append("</script>\n");
+ }
+ else if ("AJAXScripts".equals(region.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'>\n");
+
markup.append("remote_server_url=\"").append(remoteURL).append(";\"\n");
- markup.append("</script>\n");
- }
- else if ("AJAXScripts".equals(region.getId()))
- {
- disabled = Boolean.TRUE;
+ markup.append("regions_on_page = new Object();\n");
- 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'>\n");
-
markup.append("remote_server_url=\"").append(remoteURL).append(";\"\n");
+ String sendData =
+ "function sendData(action, windowId, fromPos, fromRegionId, toPos,
toRegionId)\n" +
+ "{\n" +
+ " var options = {\n" +
+ " method: 'post',\n" +
+ " postBody: 'action=' + action +
'&windowId=' + windowId + '&fromPos=' + fromPos +
'&fromRegion=' + fromRegionId + '&toPos=' + toPos +
'&toRegion=' + toRegionId,\n" +
+ " onSuccess: function(t)\n" +
+ " {\n" +
+ " },\n" +
+ " onSuccess: function(t)\n" +
+ " {\n" +
+ " },\n" +
+ " on404: function(t)\n" +
+ " {\n" +
+ " alert('Error 404: location \"' +
t.statusText + '\" was not found.');\n" +
+ " },\n" +
+ " onFailure: function(t)\n" +
+ " {\n" +
+ " alert('Error ' + t.status + ' -- ' +
t.statusText);\n" +
+ " },\n" +
+ " onLoading: function(t)\n" +
+ " {\n" +
+ " }\n" +
+ " }\n" +
+ " new Ajax.Request(remote_server_url, options);\n" +
+ "}";
+ markup.append(sendData);
- markup.append("regions_on_page = new Object();\n");
+ //
+ String t =
+ "function snapshot() {\n" +
+ "for(region in regions_on_page) {\n" +
+ "var regionId = regions_on_page[region];\n" +
+ "var regionDiv = $(region);\n" +
+ "for (var i = 0;i < regionDiv.childNodes.length;i++) {\n"
+
+ "var child = regionDiv.childNodes[i];\n" +
+ "child['regionId'] = regionId;\n" +
+ "child['pos'] = i;\n" +
+ "}\n" +
+ "}\n" +
+ "\n}";
- String sendData =
- "function sendData(action, windowId, fromPos, fromRegionId, toPos,
toRegionId)\n" +
+ markup.append(t);
+
+ String s =
+ " var WindowMoveObserver = Class.create();\n" +
+ " WindowMoveObserver.prototype =\n" +
+ " {\n" +
+ " initialize: function(element)\n" +
+ " {\n" +
+ " this.element = $(element);\n" +
+ " },\n" +
+ " onStart: function()\n" +
+ " {\n" +
+ " },\n" +
+ " onEnd: function()\n" +
+ " {\n" +
+ " var elt = Draggables.activeDraggable.element;\n" +
+ " var fromRegionId = elt['regionId'];\n" +
+ " var fromPos = elt['pos'];\n" +
+ " snapshot();\n" +
+ " var toRegionId = elt['regionId'];\n" +
+ " var toPos = elt['pos'];\n" +
+ " sendData('windowmove', elt.id, fromPos,
fromRegionId, toPos, toRegionId);\n" +
+ " }\n" +
+ " };\n";
+ markup.append(s);
+
+ String u = "function removeWindow(elementId)\n" +
"{\n" +
- " var options = {\n" +
- " method: 'post',\n" +
- " postBody: 'action=' + action +
'&windowId=' + windowId + '&fromPos=' + fromPos +
'&fromRegion=' + fromRegionId + '&toPos=' + toPos +
'&toRegion=' + toRegionId,\n" +
- " onSuccess: function(t)\n" +
- " {\n" +
- " },\n" +
- " onSuccess: function(t)\n" +
- " {\n" +
- " },\n" +
- " on404: function(t)\n" +
- " {\n" +
- " alert('Error 404: location \"' + t.statusText
+ '\" was not found.');\n" +
- " },\n" +
- " onFailure: function(t)\n" +
- " {\n" +
- " alert('Error ' + t.status + ' -- ' +
t.statusText);\n" +
- " },\n" +
- " onLoading: function(t)\n" +
- " {\n" +
- " }\n" +
- " }\n" +
- " new Ajax.Request(remote_server_url, options);\n" +
+ " var effectElement = document.getElementById(elementId)\n" +
+ " new Effect.BlindUp(effectElement);\n" +
+ "\n" +
+ " //removeElement(effectElement);\n" +
+ "\n" +
+ " sendData('windowremove', elementId);\n" +
"}";
- markup.append(sendData);
+ markup.append(u);
- //
- String t =
- "function snapshot() {\n" +
- "for(region in regions_on_page) {\n" +
- "var regionId = regions_on_page[region];\n" +
- "var regionDiv = $(region);\n" +
- "for (var i = 0;i < regionDiv.childNodes.length;i++) {\n" +
- "var child = regionDiv.childNodes[i];\n" +
- "child['regionId'] = regionId;\n" +
- "child['pos'] = i;\n" +
- "}\n" +
- "}\n" +
- "\n}";
-
- markup.append(t);
-
- String s =
- " var WindowMoveObserver = Class.create();\n" +
- " WindowMoveObserver.prototype =\n" +
- " {\n" +
- " initialize: function(element)\n" +
- " {\n" +
- " this.element = $(element);\n" +
- " },\n" +
- " onStart: function()\n" +
- " {\n" +
- " },\n" +
- " onEnd: function()\n" +
- " {\n" +
- " var elt = Draggables.activeDraggable.element;\n" +
- " var fromRegionId = elt['regionId'];\n" +
- " var fromPos = elt['pos'];\n" +
- " snapshot();\n" +
- " var toRegionId = elt['regionId'];\n" +
- " var toPos = elt['pos'];\n" +
- " sendData('windowmove', elt.id, fromPos,
fromRegionId, toPos, toRegionId);\n" +
- " }\n" +
- " };\n";
- markup.append(s);
-
- String u = "function removeWindow(elementId)\n" +
- "{\n" +
- " var effectElement = document.getElementById(elementId)\n" +
- " new Effect.BlindUp(effectElement);\n" +
- "\n" +
- " //removeElement(effectElement);\n" +
- "\n" +
- " sendData('windowremove', elementId);\n" +
- "}";
- markup.append(u);
-
- markup.append("</script>\n");
- markup.append("\n\n\n");
+ markup.append("</script>\n");
+ markup.append("\n\n\n");
+ }
+ else
+ {
+ String onRegion =
region.getProperty(ThemeConstants.PORTAL_AJAX_OBJECT_ENABLED);
+ regionEnabled = onRegion == null || "true".equals(onRegion);
+ }
}
- if (Boolean.TRUE.equals(disabled) == false)
+ //
+ if (regionEnabled)
{
- markup.append(
- "<script>" +
- "regions_on_page[\"" + renderContext.getRegionID() +
"\"]=\"" + region.getId() + "\";" +
- "</script>");
+ markup.append("<script>").
+ append("regions_on_page[\"").
+ append(renderContext.getRegionID()).
+ append("\"]=\"").
+ append(region.getId()).
+ append("\";").
+ append("</script>");
}
//
try
{
- disabledLocal.set(disabled);
+ enabledLocal.set(Boolean.valueOf(regionEnabled));
//
delegate.render(renderContext, region, portletContexts, windowResults);
}
finally
{
- disabledLocal.set(null);
+ enabledLocal.set(null);
}
//