Author: mwringe
Date: 2010-01-19 02:32:18 -0500 (Tue, 19 Jan 2010)
New Revision: 1364
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
Log:
Allow public render parameters to be removed if trying to set with an empty value.
Simplify portlet urls and use not add values for default settings (assuming defaults as
render, normal window state, and view mode).
Allow for custom modes to be used.
Minor code cleanup.
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-01-19
07:20:13 UTC (rev 1363)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-01-19
07:32:18 UTC (rev 1364)
@@ -98,36 +98,43 @@
String type;
if (containerURL instanceof RenderURL)
{
- type = "render";
+ type = Constants.PORTAL_RENDER;
}
else if (containerURL instanceof ResourceURL)
{
- type = "resource";
+ type = Constants.PORTAL_SERVE_RESOURCE;
}
else if (containerURL instanceof ActionURL)
{
- type = "action";
+ type = Constants.PORTAL_PROCESS_ACTION;
}
else
{
throw new Error("Unrecognized containerURL type");
}
- appendParameter(baseURL, "portal:type", type);
- appendParameter(baseURL, "portal:isSecure", "" +
format.getWantSecure());
-
+ if (!type.equals(Constants.PORTAL_RENDER))
+ {
+ appendParameter(baseURL, Constants.TYPE_PARAMETER, type);
+ }
+
+ if (format != null && format.getWantSecure() != null)
+ {
+ appendParameter(baseURL, Constants.SECURE_PARAMETER,
format.getWantSecure().toString());
+ }
+
if (containerURL instanceof ActionURL)
{
ActionURL actionURL = (ActionURL)containerURL;
StateString state = actionURL.getInteractionState();
- if (state != null)
+ if (state != null &&
!state.getStringValue().equals(StateString.JBPNS_PREFIX))
{
appendParameter(baseURL, INTERACTION_STATE_PARAM_NAME,
state.getStringValue());
}
-
+
state = actionURL.getNavigationalState();
- if (state != null)
+ if (state != null &&
!state.getStringValue().equals(StateString.JBPNS_PREFIX) )
{
appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME,
state.getStringValue());
}
@@ -157,13 +164,13 @@
}
StateString resourceState = resourceURL.getResourceState();
- if (resourceState != null)
+ if (resourceState != null &&
!resourceState.getStringValue().equals(StateString.JBPNS_PREFIX))
{
appendParameter(baseURL, RESOURCE_STATE_PARAM_NAME,
resourceState.getStringValue());
}
resourceState = resourceURL.getNavigationalState();
- if (resourceState != null)
+ if (resourceState != null &&
!resourceState.getStringValue().equals(StateString.JBPNS_PREFIX))
{
appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME,
resourceState.getStringValue());
}
@@ -185,13 +192,13 @@
RenderURL renderURL = (RenderURL)containerURL;
WindowState windowState = renderURL.getWindowState();
- if (windowState != null)
+ if (windowState != null && !windowState.equals(WindowState.NORMAL))
{
appendParameter(baseURL, Constants.WINDOW_STATE_PARAMETER,
windowState.toString());
}
Mode mode = renderURL.getMode();
- if (mode != null)
+ if (mode != null && !mode.equals(Mode.VIEW))
{
appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
}
@@ -201,11 +208,18 @@
{
for (String key : publicNSChanges.keySet())
{
- String[] values = publicNSChanges.get(key);
- for (String value : values)
- {
- appendParameter(baseURL, key, value);
- }
+ String[] values = publicNSChanges.get(key);
+ if (values != null && values.length > 0)
+ {
+ for (String value : values)
+ {
+ appendParameter(baseURL, key, value);
+ }
+ }
+ else
+ {
+ appendParameter(baseURL, "removePP", key);
+ }
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-01-19
07:20:13 UTC (rev 1363)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-01-19
07:32:18 UTC (rev 1364)
@@ -619,10 +619,18 @@
for (String key : requestParams.keySet())
{
- if (uiPortlet.supportsPublicParam(key))
- {
- publicParams.put(key, requestParams.get(key));
- }
+ String[] value = requestParams.get(key);
+ if (uiPortlet.supportsPublicParam(key))
+ {
+ if (value.length > 0)
+ {
+ publicParams.put(key, value);
+ }
+ else
+ {
+ publicParams.remove(key);
+ }
+ }
}
}
@@ -719,9 +727,14 @@
{
uiPortlet.setCurrentPortletMode(PortletMode.EDIT);
}
+ else if (portletMode.equals(PortletMode.VIEW.toString()))
+ {
+ uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
+ }
else
{
- uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
+ PortletMode customMode = new PortletMode(portletMode);
+ uiPortlet.setCurrentPortletMode(customMode);
}
event.getRequestContext().addUIComponentToUpdateByAjax(uiPortlet);
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-01-19
07:20:13 UTC (rev 1363)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-01-19
07:32:18 UTC (rev 1364)
@@ -24,6 +24,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.portlet.PortletExceptionHandleService;
+import org.exoplatform.portal.webui.portal.UIPortal;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.resolver.ApplicationResourceResolver;
import org.exoplatform.services.log.ExoLogger;
@@ -43,6 +44,7 @@
import java.io.Serializable;
import java.nio.charset.Charset;
+import java.util.Map;
import javax.portlet.PortletMode;
import javax.portlet.WindowState;
@@ -106,6 +108,8 @@
*
* In case of a RenderURL, the parameter state map must be invalidated and
* ths is done in the associated ActionListener
+ *
+ * If no action type is specified we assume the default, which is to render
*/
String portletActionType = context.getRequestParameter(Constants.TYPE_PARAMETER);
if (portletActionType != null)
@@ -123,14 +127,15 @@
if (event != null)
event.broadcast();
}
- else
- {
- Event<UIComponent> event = uicomponent.createEvent("Render",
Event.Phase.PROCESS, context);
- if (event != null)
- event.broadcast();
- addUpdateComponent = true;
- }
}
+ else
+ {
+ Event<UIComponent> event = uicomponent.createEvent("Render",
Event.Phase.PROCESS, context);
+ if (event != null)
+ event.broadcast();
+ addUpdateComponent = true;
+ }
+
if (addUpdateComponent)
context.addUIComponentToUpdateByAjax(uicomponent);
}
@@ -156,6 +161,16 @@
try
{
+ Map<String, String[]> paramMap = prcontext.getRequest().getParameterMap();
+ if (paramMap.containsKey("removePP"))
+ {
+ UIPortal uiPortal = Util.getUIPortal();
+ for (String publicParamName : paramMap.get("removePP"))
+ {
+ uiPortal.getPublicParameters().remove(publicParamName);
+ }
+ }
+
RenderInvocation renderInvocation = uicomponent.create(RenderInvocation.class,
prcontext);
if (uicomponent.getCurrentWindowState() != WindowState.MINIMIZED)
@@ -242,7 +257,14 @@
PortletContainerException pcException = new PortletContainerException(e);
PortletExceptionHandleService portletExceptionService =
(PortletExceptionHandleService)container.getComponentInstanceOfType(PortletExceptionHandleService.class);
- portletExceptionService.handle(pcException);
+ if (portletExceptionService != null)
+ {
+ portletExceptionService.handle(pcException);
+ }
+ else
+ {
+ log.warn("Could not find the PortletExceptionHandleService in the exo
container");
+ }
markup = Text.create("This portlet encountered an error and could not be
displayed.");
}