Author: thomas.heute(a)jboss.com
Date: 2008-06-27 08:08:04 -0400 (Fri, 27 Jun 2008)
New Revision: 11168
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editWindow.xhtml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/Content.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
Log:
Fixing content framework some more
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContent.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -26,6 +26,7 @@
import org.jboss.portal.core.model.content.spi.handler.ContentState;
import java.util.Iterator;
+import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -72,6 +73,11 @@
state.setParameter(name, value);
}
+ public void setParameters(Map<String, String> parameters) throws
IllegalArgumentException
+ {
+ state.setParameters(parameters);
+ }
+
public Iterator<String> getParameterNames()
{
return state.getParameterNames();
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -210,19 +210,17 @@
PortletInfo portletInfo = portlet.getInfo();
NavigationInfo navigationInfo = portletInfo.getNavigation();
- // todo : use instead of loop (waiting for new version of PC 2.0 that
has the method):
- //id =
navigationInfo.getPublicParameter(CoreConstants.JBOSS_PORTAL_CONTENT_URI);
- for (ParameterInfo parameterInfo :
navigationInfo.getPublicParameters())
+ ParameterInfo parameterInfo =
navigationInfo.getPublicParameter(CoreConstants.JBOSS_PORTAL_CONTENT_URI);
+ if (parameterInfo != null)
{
- if
(parameterInfo.getName().equals(CoreConstants.JBOSS_PORTAL_CONTENT_URI))
- {
- id_uri = parameterInfo.getId();
- }
- if
(parameterInfo.getName().equals(CoreConstants.JBOSS_PORTAL_CONTENT_PARAMETERS))
- {
- id_parameters = parameterInfo.getId();
- }
+ id_uri = parameterInfo.getId();
}
+
+ parameterInfo =
navigationInfo.getPublicParameter(CoreConstants.JBOSS_PORTAL_CONTENT_PARAMETERS);
+ if (parameterInfo != null)
+ {
+ id_parameters = parameterInfo.getId();
+ }
}
catch (PortletInvokerException e)
{
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/PortalObjectImpl.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -62,7 +62,7 @@
private Long key;
/** . */
- private Map declaredPropertyMap;
+ private Map<String, String> declaredPropertyMap;
/** . */
private String listener;
@@ -477,17 +477,17 @@
return unmodifiableProperties;
}
- public Map getDeclaredPropertyMap()
+ public Map<String, String> getDeclaredPropertyMap()
{
return declaredPropertyMap;
}
- public void setDeclaredPropertyMap(Map properties)
+ public void setDeclaredPropertyMap(Map<String, String> properties)
{
this.declaredPropertyMap = properties;
}
- public Map getDeclaredProperties()
+ public Map<String, String> getDeclaredProperties()
{
return Collections.unmodifiableMap(declaredPropertyMap);
}
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -35,6 +35,8 @@
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -267,6 +269,15 @@
setDeclaredProperty("content." + name, value);
}
+ public void setParameters(Map<String, String> parameters) throws
IllegalArgumentException
+ {
+ clearParameters();
+ for (Entry<String, String> entry: parameters.entrySet())
+ {
+ setParameter(entry.getKey(), entry.getValue());
+ }
+ }
+
public String getParameter(String name) throws IllegalArgumentException
{
return getDeclaredProperty("content." + name);
@@ -274,7 +285,7 @@
public void clearParameters()
{
- for (Iterator i = getDeclaredProperties().keySet().iterator(); i.hasNext();)
+ for (Iterator<String> i = getDeclaredProperties().keySet().iterator();
i.hasNext();)
{
String propertyName = (String)i.next();
if (propertyName.startsWith("content."))
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/Content.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/Content.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/Content.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -25,6 +25,7 @@
import org.jboss.portal.common.i18n.LocalizedString;
import java.util.Iterator;
+import java.util.Map;
/**
* Defines the base interface for content.
@@ -67,6 +68,8 @@
void setParameter(String name, String value) throws IllegalArgumentException;
+ void setParameters(Map<String, String> parameters) throws
IllegalArgumentException;
+
String getParameter(String name) throws IllegalArgumentException;
void clearParameters();
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentState.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.model.content.spi.handler;
import java.util.Iterator;
+import java.util.Map;
/**
* Represents the state of the content which consist in an URI and a set of properties.
@@ -50,6 +51,8 @@
void setParameter(String name, String value) throws IllegalArgumentException;
+ void setParameters(Map<String, String> parameters) throws
IllegalArgumentException;
+
String getParameter(String name) throws IllegalArgumentException;
void clearParameters();
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -38,7 +38,10 @@
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
+import javax.xml.namespace.QName;
+import org.jboss.portal.api.content.SelectedContent;
+import org.jboss.portal.core.CoreConstants;
import org.jboss.portal.core.admin.ui.actions.AddPageAction;
import org.jboss.portal.core.admin.ui.actions.PropertyAction;
import org.jboss.portal.core.admin.ui.common.PageManagerBean;
@@ -59,8 +62,13 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.faces.component.portlet.PortletActionEvent;
+import org.jboss.portal.faces.component.portlet.PortletEventEvent;
import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.info.NavigationInfo;
+import org.jboss.portal.portlet.info.ParameterInfo;
+import
org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse.Event;
import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.security.SecurityConstants;
import org.jboss.portal.security.spi.provider.DomainConfigurator;
@@ -77,6 +85,8 @@
/** . */
private static final String CONTENT_URI = "content.uri";
+ private static final QName CONTENT_SELECT = new
QName("urn:jboss:portal:content", "select");
+
// Configuration
/** . */
@@ -123,7 +133,7 @@
private Map selectedContentParameters = new HashMap();
/** . */
- private Map renderParameters;
+ private Map<String, String[]> renderParameters;
// Runtime state
@@ -490,7 +500,7 @@
{
PortalObjectId poid = getSelectedPortalObjectId();
- Map pmap = getRequestParameterMap();
+ Map<String, String> pmap = getRequestParameterMap();
maximizedStateExists =
Boolean.valueOf((String)pmap.get("maximizedStateExists"));
PortalObject object = portalObjectContainer.getObject(poid);
@@ -515,8 +525,17 @@
Content content = window.getContent();
if (content != null)
{
- renderParameters = new HashMap();
- renderParameters.put(CONTENT_URI, new String[]{content.getURI()});
+ renderParameters = new HashMap<String, String[]>();
+
+ Portlet portlet =
instanceContainer.getDefinition(getSelectedContentEditorInstance()).getPortlet();
+
+ NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
+
+ ParameterInfo parameterInfo =
navigationInfo.getPublicParameter(CoreConstants.JBOSS_PORTAL_CONTENT_URI);
+ if (parameterInfo != null)
+ {
+ renderParameters.put(parameterInfo.getId(), new
String[]{content.getURI()});
+ }
}
break;
}
@@ -534,7 +553,7 @@
private PortalObjectId getSelectedPortalObjectId()
{
// Get id
- Map pmap = getRequestParameterMap();
+ Map<String, String> pmap = getRequestParameterMap();
String id = (String)pmap.get("id");
// Set the state from the id
@@ -544,11 +563,11 @@
public void selectPlugin()
{
// Get plugin
- Map pmap = getRequestParameterMap();
+ Map<String, String> pmap = getRequestParameterMap();
selectedPlugin = (String)pmap.get("plugin");
}
- public Map getRequestParameterMap()
+ public Map<String, String> getRequestParameterMap()
{
return
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
}
@@ -709,16 +728,18 @@
public void processEvent(ActionEvent event)
{
- if (event instanceof PortletActionEvent)
+ if (event instanceof PortletEventEvent)
{
- PortletActionEvent actionEvent = (PortletActionEvent)event;
- Map actionParams = actionEvent.getParameterMap();
- if (actionParams.get("content.action.select") != null)
+ PortletEventEvent eventEvent = (PortletEventEvent)event;
+ Event portletEvent = eventEvent.getEvent();
+ QName name = portletEvent.getName();
+ // only react to content selection events
+ if(CONTENT_SELECT.equals(name))
{
- String[] uris = (String[])actionParams.get(CONTENT_URI);
- if (uris != null && uris.length > 0)
+ if (portletEvent.getPayload() instanceof String)
{
- String uri = uris[0];
+ String uri = (String)portletEvent.getPayload();
+
PortalObject po = getSelectedObject();
switch (po.getType())
{
@@ -731,6 +752,25 @@
}
}
}
+ else if (portletEvent.getPayload() instanceof SelectedContent)
+ {
+ SelectedContent selectedContent =
(SelectedContent)portletEvent.getPayload();
+ String uri= selectedContent.getUri();
+ Map<String, String> parameters = selectedContent.getParameters();
+
+ PortalObject po = getSelectedObject();
+ switch (po.getType())
+ {
+ case PortalObject.TYPE_WINDOW:
+ {
+ Window window = (Window)po;
+ window.getContent().setURI(uri);
+ window.getContent().setParameters(parameters);
+ selectParentObject(event);
+ break;
+ }
+ }
+ }
}
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -431,11 +431,12 @@
}
}
}
+ /*
else if (event instanceof PortletActionEvent)
{
PortletActionEvent actionEvent = (PortletActionEvent)event;
Map actionParams = actionEvent.getParameterMap();
-
+*/
/*
// Keep window name and region defined
String[] windowNames = ((String[])actionParams.get("windowName"));
@@ -473,7 +474,7 @@
}
}
*/
- }
+// }
}
/** Return the <Region>List on the selected object which must be a page. */
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editWindow.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editWindow.xhtml 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editWindow.xhtml 2008-06-27
12:08:04 UTC (rev 11168)
@@ -20,7 +20,8 @@
supportedModes="edit_content"
supportedWindowStates="normal"
initialMode="edit_content"
- initialWindowState="normal"/>
+ initialWindowState="normal"
+ />
</div>
</ui:define>
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java 2008-06-27
10:57:35 UTC (rev 11167)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java 2008-06-27
12:08:04 UTC (rev 11168)
@@ -554,85 +554,81 @@
writer.write(fragment.getContent());
writer.endElement("div");
- //
- if (getOnClick() != null)
- {
- writer.startElement("script", this);
- writer.write(
+ writer.startElement("script", this);
+ writer.write(
"var isIE = /msie/i.test(navigator.userAgent);\n" +
- "function attachEvent(elm, eventName, eventHandler)
{\n" +
- " if (isIE) {\n" +
- " elm.attachEvent(\"on\" + eventName,
eventHandler);\n" +
- " } else {\n" +
- " elm.addEventListener(eventName, eventHandler,
false);\n" +
- " }\n" +
- "}\n" +
+ "function attachEvent(elm, eventName, eventHandler) {\n"
+
+ " if (isIE) {\n" +
+ " elm.attachEvent(\"on\" + eventName,
eventHandler);\n" +
+ " } else {\n" +
+ " elm.addEventListener(eventName, eventHandler,
false);\n" +
+ " }\n" +
+ "}\n" +
- "function getEventTarget(event) {\n" +
- " var targetElement = isIE ? event.srcElement :
event.target;\n" +
- " while (targetElement.nodeType == 3 &&
targetElement.parentNode != null) {\n" +
- " targetElement = targetElement.parentNode;\n" +
- " }\n" +
- " return targetElement;\n" +
- "}\n" +
+ "function getEventTarget(event) {\n" +
+ " var targetElement = isIE ? event.srcElement :
event.target;\n" +
+ " while (targetElement.nodeType == 3 &&
targetElement.parentNode != null) {\n" +
+ " targetElement = targetElement.parentNode;\n" +
+ " }\n" +
+ " return targetElement;\n" +
+ "}\n" +
- "\n" +
+ "\n" +
- "function PortletURL(url) {\n" +
- " this.params = new Object();\n" +
- " this.url = url;\n" +
- " this.setParameter = function(name, value) {;\n" +
- " this.params[name] = value;\n" +
- " return this;\n" +
- " }\n" +
- " this.renderURL = function() {;\n" +
- " var tmp = this.url;\n" +
- " for (var i in this.params) {\n" +
- " tmp = tmp + ('&' + i + '=' +
this.params[i]);\n" +
- " };\n" +
- " return tmp;\n" +
- " }\n" +
+ "function PortletURL(url) {\n" +
+ " this.params = new Object();\n" +
+ " this.url = url;\n" +
+ " this.setParameter = function(name, value) {;\n" +
+ " this.params[name] = value;\n" +
+ " return this;\n" +
+ " }\n" +
+ " this.renderURL = function() {;\n" +
+ " var tmp = this.url;\n" +
+ " for (var i in this.params) {\n" +
+ " tmp = tmp + ('&' + i + '=' +
this.params[i]);\n" +
+ " };\n" +
+ " return tmp;\n" +
+ " }\n" +
- // Temporary hack for Sun RI which encodes contextual state on
the page
- " var viewStateId =
document.getElementById('javax.faces.ViewState')\n" +
- " if (viewStateId != null) {\n" +
- " this.params['javax.faces.ViewState'] =
viewStateId.value\n" +
- " }\n" +
+ // Temporary hack for Sun RI which encodes contextual state on the
page
+ " var viewStateId =
document.getElementById('javax.faces.ViewState')\n" +
+ " if (viewStateId != null) {\n" +
+ " this.params['javax.faces.ViewState'] =
viewStateId.value\n" +
+ " }\n" +
- "}\n" +
+ "}\n" +
- "function fx(event) {\n" +
- " var target = getEventTarget(event);\n" +
- " if (target.nodeName == 'INPUT' &&
target.type == 'submit') {\n" +
- " var current = target.parentNode;\n" +
- " while (current.nodeName != 'FORM' &&
current.nodeName != 'BODY') {\n" +
- " current = current.parentNode;\n" +
- " }\n" +
- " if (current.nodeName == 'FORM') {\n" +
- " var action = current.action;\n" +
- " var portletURL = new PortletURL(action);\n" +
- " (function(url){" + onClick +
"})(portletURL);\n" +
- " current.action = portletURL.renderURL();\n" +
- " } else {\n" +
- " // Really can't do nothing for now\n" +
- " }\n" +
- " }\n" +
- " else if (target.nodeName == 'A') {\n" +
- " var href = target.href;\n" +
- " var portletURL = new PortletURL(href);\n" +
- " (function(url){" + onClick +
"})(portletURL);\n" +
- " target.href = portletURL.renderURL();\n" +
- " }\n" +
- " \n" +
- "}\n" +
+ "function fx(event) {\n" +
+ " var target = getEventTarget(event);\n" +
+ " if (target.nodeName == 'INPUT' &&
target.type == 'submit') {\n" +
+ " var current = target.parentNode;\n" +
+ " while (current.nodeName != 'FORM' &&
current.nodeName != 'BODY') {\n" +
+ " current = current.parentNode;\n" +
+ " }\n" +
+ " if (current.nodeName == 'FORM') {\n" +
+ " var action = current.action;\n" +
+ " var portletURL = new PortletURL(action);\n" +
+ " (function(url){" + onClick +
"})(portletURL);\n" +
+ " current.action = portletURL.renderURL();\n" +
+ " } else {\n" +
+ " // Really can't do nothing for now\n" +
+ " }\n" +
+ " }\n" +
+ " else if (target.nodeName == 'A') {\n" +
+ " var href = target.href;\n" +
+ " var portletURL = new PortletURL(href);\n" +
+ " (function(url){" + onClick +
"})(portletURL);\n" +
+ " target.href = portletURL.renderURL();\n" +
+ " }\n" +
+ " \n" +
+ "}\n" +
- "var elt = document.getElementById('bilto');\n"
+
- "attachEvent(elt, 'click', fx);\n"
- );
- writer.endElement("script");
- }
+ "var elt = document.getElementById('bilto');\n" +
+ "attachEvent(elt, 'click', fx);\n"
+ );
+ writer.endElement("script");
writer.flush();
}
else if (pir instanceof InsufficientPrivilegesResponse){