You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2008/10/17 01:11:51 UTC
svn commit: r705398 - in /myfaces/extensions/validator/trunk:
core/src/main/java/org/apache/myfaces/extensions/validator/core/el/
examples/feature-set_01/src/main/webapp/WEB-INF/
examples/feature-set_01/src/main/webapp/components/ examples/feature-set_...
Author: gpetracek
Date: Thu Oct 16 16:11:51 2008
New Revision: 705398
URL: http://svn.apache.org/viewvc?rev=705398&view=rev
Log:
extended map syntax support
Added:
myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/main.taglib.xml
myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/components/
myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/components/user_form.xhtml
Modified:
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/FaceletsTaglibExpressionHelper.java
myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ValueBindingExpression.java
myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/web.xml
myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/pages/registration.xhtml
myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java
Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java?rev=705398&r1=705397&r2=705398&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/DefaultELHelper.java Thu Oct 16 16:11:51 2008
@@ -22,6 +22,7 @@
import org.apache.myfaces.extensions.validator.internal.Priority;
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -110,6 +111,11 @@
public ValueBindingExpression getValueBindingExpression(UIComponent uiComponent)
{
+ return getValueBindingExpression(uiComponent, false);
+ }
+
+ public ValueBindingExpression getValueBindingExpression(UIComponent uiComponent, boolean allowBlankCharacters)
+ {
String valueBindingExpression = getOriginalValueBindingExpression(uiComponent);
//for input components without value-binding
@@ -120,11 +126,39 @@
return null;
}
+ if(!allowBlankCharacters)
+ {
+ valueBindingExpression = valueBindingExpression.replace(" ", "");
+ }
+
if (getTypeOfValueBindingForExpression(FacesContext.getCurrentInstance(),
new ValueBindingExpression(valueBindingExpression).getBaseExpression()) == null)
{
- valueBindingExpression = FaceletsTaglibExpressionHelper.
+ ValueBindingExpression result = FaceletsTaglibExpressionHelper.
tryToCreateValueBindingForFaceletsBinding(uiComponent);
+
+ if(result == null)
+ {
+ if(logger.isWarnEnabled())
+ {
+ logger.warn("couldn't resolve expression: " + result.getExpressionString());
+ }
+ return null;
+ }
+
+ Class entityClass = ExtValUtils.getELHelper()
+ .getTypeOfValueBindingForExpression(FacesContext.getCurrentInstance(), result.getBaseExpression());
+
+ if(entityClass == null)
+ {
+ if(logger.isWarnEnabled())
+ {
+ logger.warn("couldn't resolve expression: " + result.getExpressionString());
+ }
+
+ return null;
+ }
+ return result;
}
return new ValueBindingExpression(valueBindingExpression);
}
Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java?rev=705398&r1=705397&r2=705398&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ELHelper.java Thu Oct 16 16:11:51 2008
@@ -47,9 +47,11 @@
ValueBindingExpression getValueBindingExpression(UIComponent uiComponent);
+ ValueBindingExpression getValueBindingExpression(UIComponent uiComponent, boolean allowBlankCharacters);
+
boolean isExpressionValid(FacesContext facesContext, String valueBindingExpression);
boolean isELTerm(Object o);
Object getBindingOfComponent(UIComponent uiComponent, String name);
-}
\ No newline at end of file
+}
Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/FaceletsTaglibExpressionHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/FaceletsTaglibExpressionHelper.java?rev=705398&r1=705397&r2=705398&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/FaceletsTaglibExpressionHelper.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/FaceletsTaglibExpressionHelper.java Thu Oct 16 16:11:51 2008
@@ -25,6 +25,7 @@
import org.apache.myfaces.extensions.validator.util.ExtValUtils;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
@@ -33,16 +34,21 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Iterator;
/**
+ * Helper class to get the real/full value binding - tested with facelets 1.1.14
+ * The target is to get rid of this impl. - currently it's a workaround to support custom facelets components.
+ * An alternative would be an EL-Resolver - there are still some open issues with such an approach
+ * + It isn't available with JSF 1.1.x
+ *
* @author Gerhard Petracek
* @since 1.x.1
*/
@UsageInformation(UsageCategory.INTERNAL)
class FaceletsTaglibExpressionHelper
{
- public static String tryToCreateValueBindingForFaceletsBinding(
- UIComponent uiComponent)
+ public static ValueBindingExpression tryToCreateValueBindingForFaceletsBinding(UIComponent uiComponent)
{
String faceletsValueBindingExpression = DefaultELHelper.getOriginalValueBindingExpression(uiComponent);
@@ -51,27 +57,36 @@
List<String> foundBindings = extractELTerms(
ExtValUtils.getELHelper().getBindingOfComponent(uiComponent, "value"));
- return faceletsValueBindingExpression.substring(0, 1) + "{" + createBinding(foundBindings) + "}";
+ Map<String, String> mappedFaceletsVars = new HashMap<String, String>();
+ ValueBindingExpression vbe= new ValueBindingExpression(faceletsValueBindingExpression
+ .substring(0, 1) + "{" + createBinding(foundBindings, mappedFaceletsVars) + "}");
+
+ Class entityClass = ExtValUtils.getELHelper()
+ .getTypeOfValueBindingForExpression(FacesContext.getCurrentInstance(), vbe.getBaseExpression());
+
+ if(entityClass == null)
+ {
+ return tryToReplaceVars(vbe, mappedFaceletsVars);
+ }
+ return vbe;
}
catch (Throwable t)
{
- return faceletsValueBindingExpression;
+ return new ValueBindingExpression(faceletsValueBindingExpression);
}
}
@ToDo(value = Priority.MEDIUM, description = "logging")
- private static String createBinding(List<String> expressions)
+ private static String createBinding(List<String> expressions, Map<String, String> virtualVars)
{
- String result = "";
-
- String prevFaceletsAttributeName = null;
String currentBinding;
- String partOfBinding;
int indexOfBindingDetails;
String[] foundBindingDetails;
String[] bindingDetails;
+ Map<String, String> addedVirtualNames = new HashMap<String, String>();
+
for (String entry : expressions)
{
if (entry.startsWith("ValueExpression["))
@@ -95,20 +110,68 @@
}
currentBinding = bindingDetails[1];
- if (prevFaceletsAttributeName != null)
+
+ //to support blanks within a binding with map syntax
+ if(currentBinding.contains("{") && !currentBinding.contains("}"))
{
- partOfBinding = currentBinding.substring(currentBinding.indexOf(prevFaceletsAttributeName)
- + prevFaceletsAttributeName.length(), currentBinding.indexOf("}"));
- result = result + partOfBinding;
+ currentBinding = addFurtherBindingParts(currentBinding, foundBindingDetails, indexOfBindingDetails);
}
- else
+
+ if (currentBinding.contains("}"))
{
- result = currentBinding.substring(currentBinding.indexOf("{") + 1, currentBinding.indexOf("}"));
+ //entry for "virtual" facelets beans
+ if(!addedVirtualNames.containsKey(bindingDetails[0]))
+ {
+ addedVirtualNames.put(bindingDetails[0], currentBinding);
+ }
}
+ //entry for "virtual" facelets var
+ if(!(currentBinding.contains("{") || currentBinding.contains("}")))
+ {
+ virtualVars.put(bindingDetails[0], bindingDetails[1].substring(1, bindingDetails[1].length()-2));
+ }
+ }
- prevFaceletsAttributeName = bindingDetails[0];
+ String originalBinding = addedVirtualNames.get("value");
+ originalBinding = originalBinding.substring(originalBinding.indexOf("{") + 1, originalBinding.indexOf("}"));
+ addedVirtualNames.remove("value");
+ return tryToTransformToRealBinding(originalBinding, addedVirtualNames);
+ }
+
+ private static String tryToTransformToRealBinding(String originalBinding, Map<String, String> addedVirtualNames)
+ {
+ originalBinding = "#{" + originalBinding + "}";
+ Iterator nameIterator = addedVirtualNames.keySet().iterator();
+
+ String currentKey;
+ String currentValue;
+ while(nameIterator.hasNext())
+ {
+ currentKey = (String) nameIterator.next();
+ currentValue = addedVirtualNames.get(currentKey);
+
+ currentValue = currentValue.substring(currentValue.indexOf("{") + 1, currentValue.indexOf("}"));
+ originalBinding = originalBinding.replace("{" + currentKey + ".", "{" + currentValue + ".");
+ originalBinding = originalBinding.replace("." + currentKey + ".", "." + currentValue + ".");
+ originalBinding = originalBinding.replace("[" + currentKey + "]", "[" + currentValue + "]");
}
- return result;
+
+ return originalBinding.substring(2, originalBinding.length() - 1);
+ }
+
+ //to support blanks - e.g. with map syntax
+ private static String addFurtherBindingParts(String currentBinding, String[] foundBindingDetails,
+ int indexOfBindingDetails)
+ {
+ for(int i = indexOfBindingDetails + 1; i < foundBindingDetails.length; i++)
+ {
+ currentBinding += foundBindingDetails[i];
+ if(foundBindingDetails[i].contains("}"))
+ {
+ return currentBinding;
+ }
+ }
+ return currentBinding;
}
private static int findIndexOfBindingDetails(String[] bindingDetails)
@@ -161,6 +224,11 @@
for (Object entry : ((Map) o).values())
{
+ //found entry for "virtual" facelets var
+ if(entry.toString().contains("ValueExpression["))
+ {
+ foundELTerms.add(entry.toString());
+ }
elCount += resolveELTerms(entry, visited, foundELTerms, count + 1);
}
return elCount;
@@ -205,7 +273,7 @@
}
List<Field> attributes = findAllAttributes(c, new ArrayList<Field>());
- Field[] fields = (Field[]) attributes.toArray(new Field[attributes.size()]);
+ Field[] fields = attributes.toArray(new Field[attributes.size()]);
AccessibleObject.setAccessible(fields, true);
for (Field currentField : fields)
@@ -253,4 +321,193 @@
return attributes;
}
+
+ private static ValueBindingExpression tryToReplaceVars(ValueBindingExpression valueBindingExpression,
+ Map<String, String> mappedFaceletsVars)
+ {
+ String property;
+ String result = "";
+ boolean last = false;
+
+ while(true)
+ {
+ if(valueBindingExpression.getBaseExpression() == null)
+ {
+ last = true;
+ }
+
+
+ property = valueBindingExpression.getProperty();
+
+ valueBindingExpression = ValueBindingExpression
+ .replaceProperty(valueBindingExpression, getNewProperty(property, mappedFaceletsVars));
+
+ if(result.length() == 0)
+ {
+ result = valueBindingExpression.getProperty();
+ }
+ else
+ {
+ result = valueBindingExpression.getProperty() + "." + result;
+ }
+
+ valueBindingExpression = valueBindingExpression.getBaseExpression();
+
+ if(last)
+ {
+ break;
+ }
+ }
+ return new ValueBindingExpression(valueBindingExpression.getPrefix() + "{" + result + "}");
+ }
+
+ private static String getNewProperty(String oldProperty, Map<String, String> mappedFaceletsVars)
+ {
+ List<String> virtualVars = getPotentialVirtualVars(oldProperty);
+
+ for(String virtualVar : virtualVars)
+ {
+ if(mappedFaceletsVars.containsKey(virtualVar))
+ {
+ oldProperty = replacePropertyValue(oldProperty, virtualVar, mappedFaceletsVars.get(virtualVar));
+ }
+ }
+ return oldProperty;
+ }
+
+ private static List<String> getPotentialVirtualVars(String oldProperty)
+ {
+ int start = -1;
+ int end = -1;
+
+ List<String> virtualVarList = new ArrayList<String>();
+
+ for(int i = 0; i < oldProperty.length(); i++)
+ {
+ if(start == - 1 && oldProperty.charAt(i) == '[')
+ {
+ start = i + 1;
+ }
+ else if((start != - 1 && oldProperty.charAt(i) == '[') || oldProperty.charAt(i) == ']')
+ {
+ end = i;
+ }
+
+ if(start != -1 && end != -1)
+ {
+ virtualVarList.add(oldProperty.substring(start, end));
+ if(oldProperty.charAt(i) == '[')
+ {
+ start = i + 1;
+ }
+ else
+ {
+ start = -1;
+ }
+ end = -1;
+ }
+ }
+
+ return virtualVarList;
+ }
+
+ private static String replacePropertyValue(String oldProperty, String targetVar, String newValue)
+ {
+ int index = oldProperty.indexOf(targetVar);
+
+ if(index == -1)
+ {
+ return oldProperty;
+ }
+
+ String result = oldProperty.substring(0, index);
+ result += newValue;
+ return result + oldProperty.substring(index + targetVar.length(), oldProperty.length());
+ }
+
+ /*
+ * replace virtual facelets vars (map syntax)
+ * tested styles (simple and nested): test[ix[ix2[ix3]]]
+ */
+ /*
+ private static String _createBinding(List<String> expressions, Map<String, String> virtualVars)
+ {
+ String result = "";
+
+ String prevFaceletsAttributeName = null;
+ String currentBinding;
+ String partOfBinding;
+
+ int indexOfBindingDetails;
+ String[] foundBindingDetails;
+ String[] bindingDetails;
+
+ List<String> addedVirtualNames = new ArrayList<String>();
+
+ for (String entry : expressions)
+ {
+ if (entry.startsWith("ValueExpression["))
+ {
+ continue;
+ }
+
+ foundBindingDetails = entry.split(" ");
+ indexOfBindingDetails = findIndexOfBindingDetails(foundBindingDetails);
+
+ if (indexOfBindingDetails == -1)
+ {
+ return null;
+ }
+
+ bindingDetails = foundBindingDetails[indexOfBindingDetails].split("=");
+
+ if (bindingDetails.length < 2)
+ {
+ return null;
+ }
+
+ currentBinding = bindingDetails[1];
+
+ //to support blanks within a binding with map syntax
+ if(currentBinding.contains("{") && !currentBinding.contains("}"))
+ {
+ currentBinding = addFurtherBindingParts(currentBinding, foundBindingDetails, indexOfBindingDetails);
+ }
+
+ if (prevFaceletsAttributeName != null && currentBinding.contains("}"))
+ {
+ //entry for "virtual" facelets beans
+ if(!addedVirtualNames.contains(bindingDetails[0]))
+ {
+ partOfBinding = currentBinding.substring(currentBinding.indexOf(prevFaceletsAttributeName)
+ + prevFaceletsAttributeName.length(), currentBinding.indexOf("}"));
+
+ addedVirtualNames.add(bindingDetails[0]);
+ result = result + partOfBinding;
+ }
+ else
+ {
+ continue;
+ }
+ }
+ //entry for "virtual" facelets var
+ else if(!(currentBinding.contains("{") || currentBinding.contains("}")))
+ {
+ virtualVars.put(bindingDetails[0], bindingDetails[1].substring(1, bindingDetails[1].length()-2));
+ continue;
+ }
+ else
+ {
+ if(!addedVirtualNames.contains(bindingDetails[0]))
+ {
+ addedVirtualNames.add(bindingDetails[0]);
+ result = currentBinding.substring(currentBinding.indexOf("{") + 1, currentBinding.indexOf("}"));
+ }
+ }
+
+ prevFaceletsAttributeName = bindingDetails[0];
+ }
+ return result;
+ }
+ */
}
\ No newline at end of file
Modified: myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ValueBindingExpression.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ValueBindingExpression.java?rev=705398&r1=705397&r2=705398&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ValueBindingExpression.java (original)
+++ myfaces/extensions/validator/trunk/core/src/main/java/org/apache/myfaces/extensions/validator/core/el/ValueBindingExpression.java Thu Oct 16 16:11:51 2008
@@ -20,12 +20,15 @@
import org.apache.myfaces.extensions.validator.internal.UsageCategory;
import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.ToDo;
+import org.apache.myfaces.extensions.validator.internal.Priority;
import org.apache.myfaces.extensions.validator.util.ExtValUtils;
/**
* @author Gerhard Petracek
* @since 1.x.1
*/
+@ToDo(value = Priority.MEDIUM, description = "difference between [ and [' - test with more constelations")
@UsageInformation({UsageCategory.API})
public class ValueBindingExpression
{
@@ -50,7 +53,19 @@
public static ValueBindingExpression replaceProperty(ValueBindingExpression valueBindingExpression,
String newProperty)
{
- return addProperty(valueBindingExpression.getBaseExpression(), newProperty);
+ if(valueBindingExpression.getProperty().endsWith("']"))
+ {
+ valueBindingExpression = valueBindingExpression.getBaseExpression();
+ }
+
+ if(valueBindingExpression.getBaseExpression() != null)
+ {
+ return addProperty(valueBindingExpression.getBaseExpression(), newProperty);
+ }
+ else
+ {
+ return addProperty(valueBindingExpression, newProperty);
+ }
}
public static ValueBindingExpression addProperty(ValueBindingExpression valueBindingExpression, String newProperty)
@@ -58,7 +73,7 @@
String sourceExpression = valueBindingExpression.getExpressionString();
String result = sourceExpression.substring(0, sourceExpression.length() - 1);
- if(newProperty.startsWith("["))
+ if(newProperty.startsWith("['"))
{
return new ValueBindingExpression(result + newProperty + "}");
}
@@ -75,7 +90,7 @@
throw new IllegalStateException(expression + " is no valid el-expression");
}
- int index1 = expression.lastIndexOf("]");
+ int index1 = expression.lastIndexOf("']");
int index2 = expression.lastIndexOf(".");
if(index1 > index2)
@@ -83,9 +98,9 @@
expression = expression.substring(0, index1);
int index3 = findIndexOfStartingBracket(expression);
- this.value = expression.substring(index3 + 1, index1);
+ this.value = expression.substring(index3 + 2, index1);
this.base = new ValueBindingExpression(expression.substring(0, index3) + "}");
- this.token = "[";
+ this.token = "['";
}
else if( index2 > index1)
{
@@ -110,7 +125,7 @@
{
return this.value.substring(1, this.value.length() - 1);
}
- return this.base.value + this.token + this.value.substring(0, this.value.length()) + "]";
+ return this.base.value + this.token + this.value.substring(0, this.value.length()) + "']";
}
return value;
}
@@ -126,9 +141,9 @@
{
String baseExpression = this.base.getExpressionString();
- if("[".equals(this.token))
+ if("['".equals(this.token))
{
- return baseExpression.substring(0, baseExpression.length() - 1) + this.token + this.value + "]}";
+ return baseExpression.substring(0, baseExpression.length() - 1) + this.token + this.value + "']}";
}
return baseExpression.substring(0, baseExpression.length() - 1) + this.token + this.value + "}";
}
@@ -188,4 +203,4 @@
}
return 0;
}
-}
\ No newline at end of file
+}
Added: myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/main.taglib.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/main.taglib.xml?rev=705398&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/main.taglib.xml (added)
+++ myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/main.taglib.xml Thu Oct 16 16:11:51 2008
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE facelet-taglib PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
+ "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
+<facelet-taglib>
+ <namespace>http://myfaces.apache.org/extval/demo/components</namespace>
+
+ <tag>
+ <tag-name>userForm</tag-name>
+ <source>
+ ../components/user_form.xhtml
+ </source>
+ </tag>
+
+</facelet-taglib>
\ No newline at end of file
Modified: myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/web.xml?rev=705398&r1=705397&r2=705398&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/WEB-INF/web.xml Thu Oct 16 16:11:51 2008
@@ -31,6 +31,11 @@
</context-param>
<context-param>
+ <param-name>facelets.LIBRARIES</param-name>
+ <param-value>/WEB-INF/main.taglib.xml</param-value>
+ </context-param>
+
+ <context-param>
<param-name>org.apache.myfaces.trinidad.ENABLE_LIGHTWEIGHT_DIALOGS</param-name>
<param-value>true</param-value>
</context-param>
Added: myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/components/user_form.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/components/user_form.xhtml?rev=705398&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/components/user_form.xhtml (added)
+++ myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/components/user_form.xhtml Thu Oct 16 16:11:51 2008
@@ -0,0 +1,32 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tr="http://myfaces.apache.org/trinidad"
+ xmlns:trh="http://myfaces.apache.org/trinidad/html">
+
+<ui:composition>
+ <tr:panelFormLayout>
+
+ <tr:inputText label="nick name" value="#{bean.person[ 'nickName' ]}"/>
+ <tr:inputText label="e-mail" value="#{bean.email}"/>
+
+ <tr:inputText label="first name" value="#{bean.person.firstName}"/>
+ <tr:inputText label="last name" value="#{bean.person.lastName}"/>
+ <tr:inputDate label="birthday" value="#{bean.person.birthday}">
+ <tr:convertDateTime type="date" dateStyle="short"/>
+ </tr:inputDate>
+ <tr:inputDate label="final exam" value="#{bean.person.finalExam}">
+ <tr:convertDateTime type="date" dateStyle="short"/>
+ </tr:inputDate>
+
+ <tr:inputText label="number of siblings" value="#{bean.numberOfSiblings}"/>
+
+ <tr:inputText label="password" value="#{bean.password}" secret="true"/>
+ <tr:inputText label="re-enter password" value="#{bean.passwordRepeated}" secret="true"/>
+
+ </tr:panelFormLayout>
+</ui:composition>
+</html>
Modified: myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/pages/registration.xhtml
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/pages/registration.xhtml?rev=705398&r1=705397&r2=705398&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/pages/registration.xhtml (original)
+++ myfaces/extensions/validator/trunk/examples/feature-set_01/src/main/webapp/pages/registration.xhtml Thu Oct 16 16:11:51 2008
@@ -13,30 +13,13 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:tr="http://myfaces.apache.org/trinidad"
- xmlns:trh="http://myfaces.apache.org/trinidad/html">
+ xmlns:trh="http://myfaces.apache.org/trinidad/html"
+ xmlns:c="http://myfaces.apache.org/extval/demo/components"
+ >
<ui:define name="content">
- <tr:panelFormLayout>
-
- <tr:inputText label="nick name" value="#{registrationPage.person[ 'nickName' ]}"/>
- <tr:inputText label="e-mail" value="#{registrationPage.email}"/>
-
- <tr:inputText label="first name" value="#{registrationPage.person.firstName}"/>
- <tr:inputText label="last name" value="#{registrationPage.person.lastName}"/>
- <tr:inputDate label="birthday" value="#{registrationPage.person.birthday}">
- <tr:convertDateTime type="date" dateStyle="short"/>
- </tr:inputDate>
- <tr:inputDate label="final exam" value="#{registrationPage.person.finalExam}">
- <tr:convertDateTime type="date" dateStyle="short"/>
- </tr:inputDate>
-
- <tr:inputText label="number of siblings" value="#{registrationPage.numberOfSiblings}"/>
-
- <tr:inputText label="password" value="#{registrationPage.password}" secret="true"/>
- <tr:inputText label="re-enter password" value="#{registrationPage.passwordRepeated}" secret="true"/>
-
- </tr:panelFormLayout>
+ <c:userForm bean="#{registrationPage}"/>
<tr:commandButton text="save" action="#{registrationPage.finish}"/>
</ui:define>
Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java?rev=705398&r1=705397&r2=705398&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java (original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java Thu Oct 16 16:11:51 2008
@@ -62,8 +62,10 @@
entry.setComponent(uiComponent);
String key = vbe.getExpressionString();
+
//for local cross-validation
if (valueBindingConvertedValueMapping.containsKey(key) &&
+ valueBindingConvertedValueMapping.get(key).getBean() != null &&
!valueBindingConvertedValueMapping.get(key).getBean().equals(entry.getBean()))
{
//for the validation within a complex component e.g. a table
@@ -87,4 +89,4 @@
valueBindingConvertedValueMapping.put(key, entry);
}
}
-}
\ No newline at end of file
+}