Author: chris.laprun(a)jboss.com
Date: 2009-06-10 18:17:58 -0400 (Wed, 10 Jun 2009)
New Revision: 13447
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/PropertiesBean.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/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java
Log:
- JBPORTAL-2409:
+ Properly inject bean context in PropertyBean and subclasses.
+ ManagedBean.PropertyValidator can now provide error message key to checkNameValidity
for better error reporting.
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-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertiesBean.java 2009-06-10
22:17:58 UTC (rev 13447)
@@ -28,6 +28,7 @@
import org.jboss.portal.common.i18n.SimpleResourceBundleFactory;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.control.ControlConstants;
+import org.jboss.portal.faces.gui.BeanContext;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
@@ -62,8 +63,10 @@
private static LocalizedString REDIRECT_TO_THE_SPECIFIED_RESOURCE = null;
private static LocalizedString REMOVE_THE_RESOURCE_FROM_PAGE = null;
- public ControlPropertiesBean(PortalObjectManagerBean pomgr)
+ public ControlPropertiesBean(PortalObjectManagerBean pomgr, BeanContext beanContext)
{
+ super(beanContext);
+
this.pomgr = pomgr;
ResourceBundleManager rbm = new ResourceBundleManager(null, new
SimpleResourceBundleFactory(BUNDLE_BASE_NAME,
PropertiesInfoBuilder.class.getClassLoader()));
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-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/ControlPropertyBean.java 2009-06-10
22:17:58 UTC (rev 13447)
@@ -24,7 +24,6 @@
package org.jboss.portal.core.admin.ui;
import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.faces.gui.ManagedBean;
import javax.faces.event.ValueChangeEvent;
@@ -55,9 +54,9 @@
}
@Override
- public ParameterValidation.ValidationErrorHandler
getValidationErrorHandler(String name, String targetForErrorMessage)
+ public String getErrorMessageKey()
{
- return new MessageValidationHandler(null, targetForErrorMessage, name,
getObjectTypeName(), ManagedBean.INVALID_PATH);
+ return ManagedBean.INVALID_PATH;
}
});
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java 2009-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertiesBean.java 2009-06-10
22:17:58 UTC (rev 13447)
@@ -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. *
@@ -24,6 +24,7 @@
import org.jboss.portal.core.admin.ui.actions.PropertyAction;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.faces.gui.BeanContext;
import javax.faces.context.FacesContext;
import javax.faces.model.DataModel;
@@ -63,8 +64,10 @@
/** . */
private String propertyActionRef;
- public PropertiesBean(PortalObjectManagerBean pomgr)
+ public PropertiesBean(PortalObjectManagerBean pomgr, BeanContext beanContext)
{
+ super(beanContext);
+
// Get the selected object
PortalObject selectedObject = pomgr.getSelectedObject();
@@ -147,7 +150,7 @@
// Add only property user can change state
if (propertyInfo.getScope() == PropertyInfo.PUBLIC_SCOPE &&
propertyInfo.getAccessMode() == PropertyInfo.READ_WRITE_ACCESS_MODE &&
!PropertiesInfo.isControlProperty(propertyName))
{
- Locale locale = FacesContext.getCurrentInstance().getExternalContext().
getRequestLocale();
+ Locale locale =
FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
items.add(new SelectItem(propertyInfo.getName(),
propertyInfo.getDisplayName().getString(locale, true),
propertyInfo.getDescription().getDefaultString()));
}
}
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-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBean.java 2009-06-10
22:17:58 UTC (rev 13447)
@@ -20,8 +20,10 @@
* 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;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.faces.gui.ManagedBean;
@@ -58,6 +60,21 @@
this.inherited = inherited;
this.inheritable = inheritable;
this.value = value;
+ setBeanContext(container.getBeanContext());
+ setValidator(new DefaultPropertyValidator()
+ {
+ @Override
+ public String doSimpleChecks(String name)
+ {
+ return name; // no-op as we want to allow / and . in paths
+ }
+
+ @Override
+ public String getErrorMessageKey()
+ {
+ return ManagedBean.INVALID_VALUE;
+ }
+ });
}
public boolean isInheritable()
@@ -104,8 +121,13 @@
public void setValue(Object value)
{
- // it's currently quite difficult to retrieve the correct target for error
messages, send them to "status"
- String propertyValue = checkNameValidity(value.toString(), null);
+ String propertyValue = value.toString();
+ if (!ParameterValidation.isNullOrEmpty(propertyValue))
+ {
+ // it's currently quite difficult to retrieve the correct target for error
messages, send them to "status"
+ propertyValue = checkNameValidity(propertyValue, null);
+ }
+
if (propertyValue != null)
{
this.value = propertyValue;
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-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/PropertyBeanContainer.java 2009-06-10
22:17:58 UTC (rev 13447)
@@ -20,6 +20,7 @@
* 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;
import org.jboss.portal.core.model.portal.PortalObject;
@@ -33,6 +34,11 @@
{
private BeanContext beanContext;
+ protected PropertyBeanContainer(BeanContext beanContext)
+ {
+ this.beanContext = beanContext;
+ }
+
public BeanContext getBeanContext()
{
return beanContext;
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-06-10
22:17:58 UTC (rev 13447)
@@ -26,7 +26,6 @@
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
import org.jboss.portal.faces.gui.ManagedBean;
-import org.jboss.portal.common.util.ParameterValidation;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
@@ -86,13 +85,7 @@
public void updateProperty()
{
- String propertyName = "";
-
- //This particular property can be null and still be valid
- if(!ParameterValidation.isNullOrEmpty(otherPropertyName)){
- propertyName = checkNameValidity(otherPropertyName,
"common-edit-prop-form:property");
- }
-
+ String propertyName = checkNameValidity(otherPropertyName,
"common-edit-prop-form:property");
if (propertyName != null)
{
if (propertyName.length() == 0 && selectedProperty != null)
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties 2009-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties 2009-06-10
22:17:58 UTC (rev 13447)
@@ -327,6 +327,7 @@
INVALID_NAME_ERROR=''{0}'' is an invalid {1} name: Cannot be null, empty
or contain '/', '.', '\\', '<', '>',
'(', ')', '=' or '%5c'
INVALID_PATH_ERROR=''{0}'' is an invalid {1} path: Cannot be null, empty
or contain '\\', '<', '>', '(', ')',
'=' or '%5c'
+INVALID_VALUE_ERROR=''{0}'' is an invalid {1} value: Cannot be contain
'\\', '<', '>', '(', ')', '=' or
'%5c'
NO_SELECTED_PORTLET_ERROR=No portlet was selected!
DUPLICATE_ERROR=A {1} named ''{0}'' already exists!
bean_support_unexpected_error=Unexpected error:
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java 2009-06-10
13:00:48 UTC (rev 13446)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java 2009-06-10
22:17:58 UTC (rev 13447)
@@ -42,6 +42,7 @@
public static final String INVALID_NAME = "INVALID_NAME_ERROR";
public static final String INVALID_PATH = "INVALID_PATH_ERROR";
public static final String DUPLICATE = "DUPLICATE_ERROR";
+ public static final String INVALID_VALUE = "INVALID_VALUE_ERROR";
public static interface PropertyValidator
{
@@ -56,6 +57,8 @@
ParameterValidation.ValidationErrorHandler getValidationErrorHandler(String name,
String targetForErrorMessage);
Pattern getValidationPattern();
+
+ String getErrorMessageKey();
}
private PropertyValidator validator = new DefaultPropertyValidator();
@@ -82,7 +85,7 @@
String objectTypeName = validator.getObjectTypeName();
if (ParameterValidation.isNullOrEmpty(name))
{
- beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
name, getLocalizedType(objectTypeName));
+ beanContext.createTargetedErrorMessage(targetForErrorMessage,
validator.getErrorMessageKey(), name, getLocalizedType(objectTypeName));
return null;
}
else
@@ -93,7 +96,7 @@
// we got an invalid name after simple checks, fail!
if (name == null)
{
- beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
original, getLocalizedType(objectTypeName));
+ beanContext.createTargetedErrorMessage(targetForErrorMessage,
validator.getErrorMessageKey(), original, getLocalizedType(objectTypeName));
return null;
}
@@ -229,12 +232,17 @@
public ParameterValidation.ValidationErrorHandler getValidationErrorHandler(String
name, String targetForErrorMessage)
{
- return new MessageValidationHandler(null, targetForErrorMessage, name,
getObjectTypeName());
+ return new MessageValidationHandler(null, targetForErrorMessage, name,
getObjectTypeName(), getErrorMessageKey());
}
public Pattern getValidationPattern()
{
return ParameterValidation.XSS_CHECK;
}
+
+ public String getErrorMessageKey()
+ {
+ return INVALID_NAME;
+ }
}
}