myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1099842 - in /myfaces/commons/branches/jsf_20: examples/myfaces-commons-facelets-examples/src/main/webapp/validateCompareTo.xhtml myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
Date Thu, 05 May 2011 15:28:24 GMT
Author: lu4242
Date: Thu May  5 15:28:24 2011
New Revision: 1099842

URL: http://svn.apache.org/viewvc?rev=1099842&view=rev
Log:
MFCOMMONS-32 mcv:validateCompareTo uses "for" attribute to identify the target component,
but JSF 2.0 facelets reserves that property name for composite components

Modified:
    myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateCompareTo.xhtml
    myfaces/commons/branches/jsf_20/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java

Modified: myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateCompareTo.xhtml
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateCompareTo.xhtml?rev=1099842&r1=1099841&r2=1099842&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateCompareTo.xhtml
(original)
+++ myfaces/commons/branches/jsf_20/examples/myfaces-commons-facelets-examples/src/main/webapp/validateCompareTo.xhtml
Thu May  5 15:28:24 2011
@@ -44,37 +44,37 @@
 			
 			<h:outputLabel for="eqInput" value="#{example_messages['validate_equal']}" />
 			<h:inputText id="eqInput" required="true">
-				<mcv:validateCompareTo for="baseInput" operator="eq" />
+				<mcv:validateCompareTo forId="baseInput" operator="eq" />
 			</h:inputText>
 			<h:message id="eqError" for="eqInput" styleClass="error" />
 			
 			<h:outputLabel for="neInput" value="#{example_messages['validate_notequal']}" />
 			<h:inputText id="neInput" required="true">
-				<mcv:validateCompareTo for="baseInput" operator="ne" />
+				<mcv:validateCompareTo forId="baseInput" operator="ne" />
 			</h:inputText>
 			<h:message id="neError" for="neInput" styleClass="error" />
 			
 			<h:outputLabel for="gtInput" value="#{example_messages['validate_greaterthan']}" />
 			<h:inputText id="gtInput" required="true">
-				<mcv:validateCompareTo for="baseInput" operator="gt" />
+				<mcv:validateCompareTo forId="baseInput" operator="gt" />
 			</h:inputText>
 			<h:message id="gtError" for="gtInput" styleClass="error" />
 			
 			<h:outputLabel for="geInput" value="#{example_messages['validate_greaterthanequal']}"
/>
 			<h:inputText id="geInput" required="true">
-				<mcv:validateCompareTo for="baseInput" operator="ge" />
+				<mcv:validateCompareTo forId="baseInput" operator="ge" />
 			</h:inputText>
 			<h:message id="geError" for="geInput" styleClass="error" />
 			
 			<h:outputLabel for="ltInput" value="#{example_messages['validate_lessthan']}" />
 			<h:inputText id="ltInput" required="true">
-				<mcv:validateCompareTo for="baseInput" operator="lt" />
+				<mcv:validateCompareTo forId="baseInput" operator="lt" />
 			</h:inputText>
 			<h:message id="ltError" for="ltInput" styleClass="error" />
 			
 			<h:outputLabel for="leInput" value="#{example_messages['validate_lessthanequal']}"
/>
 			<h:inputText id="leInput" required="true">
-					<mcv:validateCompareTo for="baseInput" operator="le" />
+					<mcv:validateCompareTo forId="baseInput" operator="le" />
 				</h:inputText>
 			<h:message id="leError" for="leInput" styleClass="error" />
 			

Modified: myfaces/commons/branches/jsf_20/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/branches/jsf_20/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java?rev=1099842&r1=1099841&r2=1099842&view=diff
==============================================================================
--- myfaces/commons/branches/jsf_20/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
(original)
+++ myfaces/commons/branches/jsf_20/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractCompareToValidator.java
Thu May  5 15:28:24 2011
@@ -229,6 +229,10 @@ public abstract class AbstractCompareToV
         }
 
         String foreignComponentName = getFor();
+        foreignComponentName = (foreignComponentName != null && foreignComponentName.length()
> 0) ? foreignComponentName : getForId();
+        if (foreignComponentName == null) {
+            throw new FacesException("No id set to compare. Use 'for' in jsp mode and 'forId'
in facelets mode");
+        }
 
         UIComponent foreignComponent = (UIComponent) uiComponent.getParent().findComponent(foreignComponentName);
         if(foreignComponent == null)
@@ -353,6 +357,10 @@ public abstract class AbstractCompareToV
     /**
      * The JSF id of the component with which to compare values.
      * 
+     * In JSF 2.0 facelets mode is used to identify the components this 
+     * validator should be applied to when using composite components.
+     * Please use forId in that case instead.
+     * 
      * @return the foreign component_id, on which a value should be validated
      */
     @JSFProperty
@@ -362,6 +370,20 @@ public abstract class AbstractCompareToV
      * @param string the foreign component_id, on which a value should be validated
      */
     public abstract void setFor(String string);
+    
+    /**
+     * The JSF id of the component with which to compare values.
+     * 
+     * @return
+     */
+    @JSFProperty(faceletsOnly=true)
+    public abstract String getForId();
+    
+    /**
+     * 
+     * @param string the foreign component_id, on which a value should be validated
+     */
+    public abstract void setForId(String string);
 
     /**
      * Operator for comparison: equals: eq, ==, =, not equals: ne, !=, greater than: gt,
&gt;, less than: lt, &lt;, greater than or equals: ge, &gt;=, less than or equals:
le, &lt;=



Mime
View raw message