Author: chris.laprun(a)jboss.com
Date: 2009-05-18 11:38:03 -0400 (Mon, 18 May 2009)
New Revision: 13388
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertiesBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertyBean.java
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/PropertyBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBeanContainer.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
Log:
- JBEPP-84: Use proper messageTarget for addPageAction so that error message is properly
displayed.
- JBEPP-83: PropertyBeans now extend ManagedBean so that they can validate their values
before saving them.
- Now inject bean context in PortalObjectManagerBean so that it can be made available to
children beans.
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertiesBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertiesBean.java 2009-05-18
00:12:44 UTC (rev 13387)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertiesBean.java 2009-05-18
15:38:03 UTC (rev 13388)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
package org.jboss.portal.core.admin.ui;
@@ -32,7 +33,6 @@
import javax.faces.model.SelectItem;
import javax.portlet.PortletConfig;
import javax.portlet.PortletRequest;
-
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -65,7 +65,7 @@
public ControlPropertiesBean(PortalObjectManagerBean pomgr)
{
this.pomgr = pomgr;
-
+
ResourceBundleManager rbm = new ResourceBundleManager(null, new
SimpleResourceBundleFactory(BUNDLE_BASE_NAME,
PropertiesInfoBuilder.class.getClassLoader()));
// Load all supported locales
@@ -74,11 +74,11 @@
while (locales.hasMoreElements())
{
Locale locale = locales.nextElement();
- rbm.getResourceBundle(locale);
+ rbm.getResourceBundle(locale);
}
DISPLAY_THE_DEFAULT_ERROR_MESSAGE =
rbm.getLocalizedValue("DISPLAY_THE_DEFAULT_ERROR_MESSAGE", "Display the
default error message");
- REDIRECT_TO_THE_SPECIFIED_RESOURCE =
rbm.getLocalizedValue("REDIRECT_TO_THE_SPECIFIED_RESOURCE", "Redirect to
the specified resource");
- REMOVE_THE_RESOURCE_FROM_PAGE =
rbm.getLocalizedValue("REMOVE_THE_RESOURCE_FROM_PAGE", "Remove the resource
from page");
+ REDIRECT_TO_THE_SPECIFIED_RESOURCE =
rbm.getLocalizedValue("REDIRECT_TO_THE_SPECIFIED_RESOURCE", "Redirect to
the specified resource");
+ REMOVE_THE_RESOURCE_FROM_PAGE =
rbm.getLocalizedValue("REMOVE_THE_RESOURCE_FROM_PAGE", "Remove the resource
from page");
portalSelectItems = new HashMap<Locale, List<SelectItem>>();
pageSelectItems = new HashMap<Locale, List<SelectItem>>();
}
@@ -132,7 +132,9 @@
boolean inheritable = object.getType() != PortalObject.TYPE_CONTEXT;
boolean inherited = !object.getDeclaredProperties().containsKey(name);
String value = object.getProperty(name);
- return new ControlPropertyBean(this, info.getPropertyInfo(name), inherited,
inheritable, value);
+ ControlPropertyBean bean = new ControlPropertyBean(this,
info.getPropertyInfo(name), inherited, inheritable, value);
+ bean.setBeanContext(getBeanContext()); // propagate bean context to chilren beans
+ return bean;
}
public ControlPropertyBean getPageControlAccessDenied()
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertyBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertyBean.java 2009-05-18
00:12:44 UTC (rev 13387)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertyBean.java 2009-05-18
15:38:03 UTC (rev 13388)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
package org.jboss.portal.core.admin.ui;
@@ -69,7 +70,9 @@
public void setValue(Object value)
{
- if (!inherited)
+ // it's currently quite difficult to retrieve the correct target for error
messages, send them to "status"
+ String propertyValue = checkNameValidity(value.toString(), null);
+ if (propertyValue != null && !inherited)
{
this.value = value.toString();
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 2009-05-18
00:12:44 UTC (rev 13387)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2009-05-18
15:38:03 UTC (rev 13388)
@@ -45,7 +45,7 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.faces.component.portlet.PortletEventEvent;
-import org.jboss.portal.faces.gui.JSFBeanContext;
+import org.jboss.portal.faces.gui.BeanContext;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletInvoker;
@@ -168,6 +168,8 @@
/** . */
private transient Boolean maximizedStateExists;
+ private transient BeanContext beanContext;
+
// Wired services
public String getNamespace()
@@ -180,6 +182,16 @@
this.namespace = namespace;
}
+ public BeanContext getBeanContext()
+ {
+ return beanContext;
+ }
+
+ public void setBeanContext(BeanContext beanContext)
+ {
+ this.beanContext = beanContext;
+ }
+
public List getAvailableContentTypes()
{
LinkedList<SelectItem> types = new LinkedList<SelectItem>();
@@ -655,20 +667,20 @@
{
if (pageManager == null)
{
- // it'd be better if propertyAction was injected in faces-config.xml so
that we can also inject the shared beanContext
pageManager = new PageManagerBean(layoutService, portletDefinitionInvoker);
- pageManager.setBeanContext(new JSFBeanContext());
+ pageManager.setBeanContext(beanContext);
}
pageManager.page = (Page)selectedObject;
}
//
selectedProperties = new PropertiesBean(this);
+ selectedProperties.setBeanContext(beanContext);
controlProperties = new ControlPropertiesBean(this);
+ controlProperties.setBeanContext(beanContext);
- // it'd be better if propertyAction was injected in faces-config.xml so that we
can also inject the shared beanContext
propertyAction = new PropertyAction(this);
- propertyAction.setBeanContext(new JSFBeanContext());
+ propertyAction.setBeanContext(beanContext);
//
theme = new ThemeBean(selectedObject);
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java 2009-05-18
00:12:44 UTC (rev 13387)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java 2009-05-18
15:38:03 UTC (rev 13388)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -22,17 +22,18 @@
******************************************************************************/
package org.jboss.portal.core.admin.ui;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.faces.gui.ManagedBean;
+
import javax.faces.context.FacesContext;
-import org.jboss.portal.core.model.portal.PortalObject;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
* @version $Revision$
*/
-public class PropertyBean implements Comparable
+public class PropertyBean extends ManagedBean implements Comparable
{
/** . */
@@ -103,23 +104,28 @@
public void setValue(Object value)
{
- this.value = value.toString();
+ // it's currently quite difficult to retrieve the correct target for error
messages, send them to "status"
+ String propertyValue = checkNameValidity(value.toString(), null);
+ if (propertyValue != null)
+ {
+ this.value = propertyValue;
- // Need to use the container as it will contain the refreshed object
- PortalObject portalObject = container.getRelatedObject();
+ // Need to use the container as it will contain the refreshed object
+ PortalObject portalObject = container.getRelatedObject();
- //if value is inherited check if updated value is the same - if yes, don't
update to keep inheritance
- if (isInherited())
- {
- String parentValue = portalObject.getProperty(getName());
- if (value.equals(parentValue))
+ //if value is inherited check if updated value is the same - if yes, don't
update to keep inheritance
+ if (isInherited())
{
- return;
+ String parentValue = portalObject.getProperty(getName());
+ if (value.equals(parentValue))
+ {
+ return;
+ }
}
+
+ //
+ portalObject.setDeclaredProperty(getName(), propertyValue);
}
-
- //
- portalObject.setDeclaredProperty(getName(), value.toString());
}
public int compareTo(Object o)
@@ -142,4 +148,14 @@
{
return "PropertyBean[name=" + info.getName() + ",value=" +
value + "]";
}
+
+ protected String getObjectTypeName()
+ {
+ return "PROPERTY_TYPE";
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return false; // no need to check for duplicates here
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBeanContainer.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBeanContainer.java 2009-05-18
00:12:44 UTC (rev 13387)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBeanContainer.java 2009-05-18
15:38:03 UTC (rev 13388)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -23,6 +23,7 @@
package org.jboss.portal.core.admin.ui;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.faces.gui.BeanContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -30,7 +31,18 @@
*/
public abstract class PropertyBeanContainer
{
+ private BeanContext beanContext;
+ public BeanContext getBeanContext()
+ {
+ return beanContext;
+ }
+
+ public void setBeanContext(BeanContext beanContext)
+ {
+ this.beanContext = beanContext;
+ }
+
public abstract PortalObject getRelatedObject();
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2009-05-18
00:12:44 UTC (rev 13387)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2009-05-18
15:38:03 UTC (rev 13388)
@@ -103,6 +103,11 @@
<property-name>coordinationService</property-name>
<value>#{applicationScope.CoordinationService}</value>
</managed-property>
+ <managed-property>
+ <property-name>beanContext</property-name>
+
<property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>portalAction</managed-bean-name>
@@ -128,7 +133,7 @@
</managed-property>
<managed-property>
<property-name>messageTarget</property-name>
- <value>addPageForm:pageName</value>
+ <value>create-page-form:pageName</value>
</managed-property>
<managed-property>
<property-name>listener</property-name>