try
{
if (mode.equals(PortletMode.HELP) || !state.equals(WindowState.NORMAL))
{
// switch back to VIEW mode and NORMAL state.
PortalURL portalURL = requestContext.getPortalURL();
String action = requestContext.getResponse().encodeURL( (isAjaxRequest)
? portalURL.createNavigationalEncoding(window, PortletMode.VIEW, WindowState.NORMAL)
: portalURL.createPortletURL(window, PortletMode.VIEW, WindowState.NORMAL, portalURL.isSecure()).toString() );
String actionName = PortletMode.VIEW.toString();
pageModes.add(new DecoratorAction(actionName, requestContext.getLocale(), decoration.getResource("images/" + actionName + ".gif"),action,DecoratorActionTemplate.ACTION_TYPE_MODE));
}
else if ( pageActionAccess.isEditAllowed() )
{
String targetMode = pageActionAccess.isEditing() ? PortletMode.VIEW.toString() : PortletMode.EDIT.toString();
PortalURL portalURL = requestContext.getPortalURL();
HashMap parameters = new HashMap();
String[] paramValues = new String[]{targetMode};
parameters.put("pageMode",paramValues);
// Use an ActionURL to set the oposite pageMode and always set VIEW mode and state NORMAL
String action = requestContext.getResponse().encodeURL( (isAjaxRequest)
? portalURL.createNavigationalEncoding(window, parameters, PortletMode.VIEW, WindowState.NORMAL, true)
: portalURL.createPortletURL(window, parameters, PortletMode.VIEW, WindowState.NORMAL, true, portalURL.isSecure()).toString() );
pageModes.add(new DecoratorAction(targetMode, requestContext.getLocale(), decoration.getResource("images/" + targetMode + ".gif"), action,DecoratorActionTemplate.ACTION_TYPE_MODE));
//window.getPortletEntity().getPortletDefinition().getInitParameterSet().get( "xxxx" );
if (content.supportsPortletMode(PortletMode.HELP))
{
if ( pageActionAccess.isEditing() )
{
// force it back to VIEW mode first with an ActionURL, as well as setting HELP mode and MAXIMIZED state
paramValues[0] = PortletMode.VIEW.toString();
action = requestContext.getResponse().encodeURL( (isAjaxRequest)
? portalURL.createNavigationalEncoding(window, parameters, PortletMode.HELP, WindowState.MAXIMIZED, true)
: portalURL.createPortletURL(window, parameters, PortletMode.HELP, WindowState.MAXIMIZED, true, portalURL.isSecure()).toString() );
}
else
{
// switch to mode HELP and state MAXIMIZED
action = requestContext.getResponse().encodeURL( (isAjaxRequest)
? portalURL.createNavigationalEncoding(window, PortletMode.HELP, WindowState.MAXIMIZED)
: portalURL.createPortletURL(window,PortletMode.HELP, WindowState.MAXIMIZED, portalURL.isSecure()).toString() );
}
String actionName = PortletMode.HELP.toString();
pageModes.add(new DecoratorAction(actionName, requestContext.getLocale(), decoration.getResource("images/" + actionName + ".gif"), action,DecoratorActionTemplate.ACTION_TYPE_MODE));
}
}