com.mycompany.jsf.validator
Class LaterThanValidator
java.lang.Object
com.mycompany.jsf.validator.LaterThanValidator
- All Implemented Interfaces:
- java.util.EventListener, java.io.Serializable, javax.faces.validator.Validator
- public class LaterThanValidator
- extends java.lang.Object
- implements javax.faces.validator.Validator, java.io.Serializable
This class is a JSF Validator that validates that the java.util.Date
value of the component it's attached to is later than the
java.util.Date value of another component.
- Version:
- 1.0
- Author:
- Hans Bergsten, Gefion Software
- See Also:
- Serialized Form
Field Summary |
private java.lang.String |
peerId
|
Fields inherited from interface javax.faces.validator.Validator |
NOT_IN_RANGE_MESSAGE_ID |
Method Summary |
private java.lang.String |
formatDate(java.util.Date date,
javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
Returns the provided Date formatted with the converter attached
to the component, if any, or with toString() otherwise. |
void |
setPeerId(java.lang.String peerId)
Sets the ID for the peer component the main component's
value is compared to. |
void |
validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
java.lang.Object value)
Compares the provided value to the value of the peer component,
and throws a ValidatorException with an appropriate FacesMessage
if the provided value doesn't represent a later date or if
there are problems accessing the peer component value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
peerId
private java.lang.String peerId
LaterThanValidator
public LaterThanValidator()
setPeerId
public void setPeerId(java.lang.String peerId)
- Sets the ID for the peer component the main component's
value is compared to. It must be a format that can be
used with the javax.faces.component.UIComponent findComponent()
method.
validate
public void validate(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
java.lang.Object value)
throws javax.faces.validator.ValidatorException
- Compares the provided value to the value of the peer component,
and throws a ValidatorException with an appropriate FacesMessage
if the provided value doesn't represent a later date or if
there are problems accessing the peer component value.
- Specified by:
validate
in interface javax.faces.validator.Validator
- Throws:
javax.faces.validator.ValidatorException
formatDate
private java.lang.String formatDate(java.util.Date date,
javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
- Returns the provided Date formatted with the converter attached
to the component, if any, or with toString() otherwise.