myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r681739 - in /myfaces/extensions/validator/trunk: core/src/main/java/org/apache/myfaces/extensions/validator/core/ core/src/main/java/org/apache/myfaces/extensions/validator/util/ validation-modules/property-validation/src/main/java/org/apa...
Date Fri, 01 Aug 2008 16:28:09 GMT
Author: gpetracek
Date: Fri Aug  1 09:28:08 2008
New Revision: 681739

URL: http://svn.apache.org/viewvc?rev=681739&view=rev
Log:
minor fix and refactoring

Modified:
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValConverter.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ELUtils.java
    myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
    myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValConverter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValConverter.java?rev=681739&r1=681738&r2=681739&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValConverter.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/ExtValConverter.java
Fri Aug  1 09:28:08 2008
@@ -111,7 +111,7 @@
         }
 
         entry = new ProcessedInformationEntry();
-        entry.setBean(ELUtils.getBeanObject(valueBindingExpression, uiComponent));
+        entry.setBean(ELUtils.getBaseObject(valueBindingExpression, uiComponent));
         entry.setConvertedValue(convertedObject);
         entry.setComponent(uiComponent);
 

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ELUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ELUtils.java?rev=681739&r1=681738&r2=681739&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ELUtils.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ELUtils.java
Fri Aug  1 09:28:08 2008
@@ -41,36 +41,41 @@
     }
 
     //TODO refactor - problem - static values - jsf 1.2 e.g.: ${value}
-    public static Object getBeanObject(String valueBindingExpression, UIComponent uiComponent)
{
+    public static Object getBaseObject(String valueBindingExpression, UIComponent uiComponent)
{
         if (valueBindingExpression.lastIndexOf(".") == -1) {
             return uiComponent.getValueExpression("value").getValue(FacesContext.getCurrentInstance().getELContext());
         }
-        return getBeanObject(valueBindingExpression);
+        return getBaseObject(valueBindingExpression);
     }
 
-    public static Object getBeanObject(String valueBindingExpression) {
+    public static Object getBaseObject(String valueBindingExpression) {
         String newExpression = valueBindingExpression.substring(0, valueBindingExpression.lastIndexOf("."))
+ "}";
 
         return getValueOfExpression(FacesContext.getCurrentInstance(), newExpression);
     }
 
     public static Object getValueOfExpression(FacesContext facesContext, String valueBindingExpression)
{
-        return (valueBindingExpression != null) ? facesContext.getApplication().createValueBinding(valueBindingExpression).getValue(facesContext)
: null;
+        return (valueBindingExpression != null) ? facesContext.getApplication().evaluateExpressionGet(facesContext,
valueBindingExpression, Object.class) : null;
     }
 
     public static boolean isExpressionValid(FacesContext facesContext, String valueBindingExpression)
{
-        return facesContext.getApplication().createValueBinding(valueBindingExpression) !=
null;
+        try {
+            facesContext.getApplication().evaluateExpressionGet(facesContext, valueBindingExpression,
Object.class);
+        } catch (Throwable t) {
+            return false;
+        }
+        return true;
     }
 
     public static String getReliableValueBindingExpression(UIComponent uiComponent) {
         String valueBindingExpression = getValueBindingExpression(uiComponent);
 
         String baseExpression = valueBindingExpression;
-        if(baseExpression.contains(".")) {
+        if (baseExpression.contains(".")) {
             baseExpression = baseExpression.substring(0, valueBindingExpression.lastIndexOf("."))
+ "}";
         }
 
-        if(getTypeOfValueBindingForExpression(FacesContext.getCurrentInstance(), baseExpression)
== null) {
+        if (getTypeOfValueBindingForExpression(FacesContext.getCurrentInstance(), baseExpression)
== null) {
             valueBindingExpression = FaceletsTaglibExpressionUtils.tryToCreateValueBindingForFaceletsBinding(uiComponent);
         }
         return valueBindingExpression;

Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java?rev=681739&r1=681738&r2=681739&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
(original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/util/ExtValUtils.java
Fri Aug  1 09:28:08 2008
@@ -275,7 +275,7 @@
         FacesContext facesContext = FacesContext.getCurrentInstance();
         String clientId = component.getClientId(facesContext);
 
-        if (clientId.substring(clientId.lastIndexOf(":")).endsWith(endOfKey)) {
+        if (clientId.contains(":") && clientId.substring(clientId.lastIndexOf(":")).endsWith(endOfKey))
{
             return component;
         }
 

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java?rev=681739&r1=681738&r2=681739&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java
Fri Aug  1 09:28:08 2008
@@ -44,7 +44,7 @@
         CrossValidationStorageEntry entry = new CrossValidationStorageEntry();
 
         entry.setAnnotationEntry(annotationEntry);
-        entry.setBean(ELUtils.getBeanObject(annotationEntry.getValueBindingExpression()));
+        entry.setBean(ELUtils.getBaseObject(annotationEntry.getValueBindingExpression()));
         entry.setComponent(uiComponent);
         entry.setConvertedObject(convertedObject);
         entry.setValidationStrategy(this);



Mime
View raw message