1 16 package org.apache.cocoon.faces.taglib; 17 18 import org.xml.sax.Attributes ; 19 import org.xml.sax.SAXException ; 20 21 import javax.faces.validator.Validator; 22 import javax.faces.validator.LengthValidator; 23 24 import org.apache.cocoon.faces.FacesUtils; 25 26 29 public class ValidateLengthTag extends ValidatorTag { 30 31 private String minimum; 32 private String maximum; 33 34 public void setMaximum(String maximum) { 35 this.maximum = maximum; 36 } 37 38 public void setMinimum(String minimum) { 39 this.minimum = minimum; 40 } 41 42 public int doStartTag(String namespaceURI, String localName, String qName, Attributes atts) 43 throws SAXException { 44 super.setValidatorId("javax.faces.Length"); 45 return super.doStartTag(namespaceURI, localName, qName, atts); 46 } 47 48 protected Validator createValidator() { 49 final UIComponentTag tag = FacesUtils.findParentUIComponentTag(this); 50 LengthValidator validator = (LengthValidator) super.createValidator(); 51 52 if (maximum != null) { 53 validator.setMaximum(tag.evaluateInteger(maximum)); 54 } 55 if (minimum != null) { 56 validator.setMinimum(tag.evaluateInteger(minimum)); 57 } 58 59 return validator; 60 } 61 62 public void recycle() { 63 super.recycle(); 64 this.minimum = null; 65 this.maximum = null; 66 } 67 } 68 | Popular Tags |