You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ba...@apache.org on 2006/10/26 13:43:31 UTC

svn commit: r467965 - /myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/ValidateLengthTag.java

Author: baranda
Date: Thu Oct 26 04:43:31 2006
New Revision: 467965

URL: http://svn.apache.org/viewvc?view=rev&rev=467965
Log:
Applied patch for MYFACES-1460 (Implement JSR-252 core tag: ValidateLengthTag). Thanks to Andreas Berger

Modified:
    myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/ValidateLengthTag.java

Modified: myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/ValidateLengthTag.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/ValidateLengthTag.java?view=diff&rev=467965&r1=467964&r2=467965
==============================================================================
--- myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/ValidateLengthTag.java (original)
+++ myfaces/core/branches/jsf12/impl/src/main/java/org/apache/myfaces/taglib/core/ValidateLengthTag.java Thu Oct 26 04:43:31 2006
@@ -17,12 +17,8 @@
 
 import org.apache.myfaces.convert.ConverterUtils;
 
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
 import javax.faces.validator.LengthValidator;
 import javax.faces.validator.Validator;
-import javax.faces.webapp.UIComponentTag;
-import javax.faces.webapp.ValidatorTag;
 import javax.servlet.jsp.JspException;
 
 /**
@@ -31,62 +27,34 @@
  * @version $Revision$ $Date$
  */
 public class ValidateLengthTag
-    extends ValidatorTag
+    extends GenericMinMaxValidatorTag<Integer>
 {
     private static final long serialVersionUID = 4858632671998693059L;
-    private String _minimum = null;
-    private String _maximum = null;
 
     private static final String VALIDATOR_ID = "javax.faces.Length";
 
-    public void release()
-    {
-        _minimum = null;
-        _maximum  = null;
-    }
-
-    public void setMinimum(String minimum)
-    {
-        _minimum = minimum;
-    }
-
-    public void setMaximum(String maximum)
-    {
-        _maximum = maximum;
-    }
-
     protected Validator createValidator()
         throws JspException
     {
-        FacesContext facesContext = FacesContext.getCurrentInstance();
-        setValidatorId(VALIDATOR_ID);
+        setValidatorIdString(VALIDATOR_ID);
         LengthValidator validator = (LengthValidator)super.createValidator();
-        if (_minimum != null)
-        {
-            if (UIComponentTag.isValueReference(_minimum))
-            {
-                ValueBinding vb = facesContext.getApplication().createValueBinding(_minimum);
-                validator.setMinimum(ConverterUtils.convertToInt(vb.getValue(facesContext)));
-            }
-            else
-            {
-                validator.setMinimum(ConverterUtils.convertToInt(_minimum));
-            }
+        if (null != _min){
+            validator.setMinimum(_min);
         }
-        if (_maximum != null)
-        {
-            if (UIComponentTag.isValueReference(_maximum))
-            {
-                ValueBinding vb = facesContext.getApplication().createValueBinding(_maximum);
-                validator.setMaximum(ConverterUtils.convertToInt(vb.getValue(facesContext)));
-            }
-            else
-            {
-                validator.setMaximum(ConverterUtils.convertToInt(_maximum));
-            }
+        if (null != _max){
+            validator.setMaximum(_max);
         }
         return validator;
     }
 
 
+    protected boolean isMinLTMax()
+    {
+        return _min < _max;
+    }
+
+    protected Integer getValue(Object value)
+    {
+        return ConverterUtils.convertToInt(value);
+    }
 }