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