Hi Ben,
Yes, you could implement a custom validation rule and probably put it
on either property. The actual method you implement will have a
signature
public static boolean validateFromToDates(
Java.lang.Object bean,
org.apache.commons.validator.ValidatorAction va,
org.apache.commons.validator.Field field,
org.apache.struts.action.ActionMessages errors,
javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext servletContext )
...where the bean argument will be your form bean. It will already be
populated so you can get both the from and to properties to compare.
Kind regards,
Carlin
On 5/3/07, Burgess, Benjamin <[EMAIL PROTECTED]> wrote:
I am having trouble figuring out how to add a custom validation rule to
a form. This is my form bean in the pageflow:
@SuppressWarnings("serial")
@Jpf.FormBean
public static class MyFormBean implements Serializable {
private String to;
private String from;
public MyFormBean() {
}
@Jpf.ValidatableProperty(displayName = "To Date",
validateRequired = @Jpf.ValidateRequired(), validateDate =
@Jpf.ValidateDate(pattern = "MM/dd/yyyy"))
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
@Jpf.ValidatableProperty(displayName = "From Date",
validateRequired = @Jpf.ValidateRequired(), validateDate =
@Jpf.ValidateDate(pattern = "MM/dd/yyyy"))
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
}
It is successfully checking that the dates are passed in and in the
correct format, but now I want to make sure that the "from date" is
before the "to date". What is the most correct way to do this? Should
I use the "Jpf.ValidateCustomRule
<http://beehive.apache.org/docs/1.0/apidocs/classref_netui/org/apache/be
ehive/netui/pageflow/annotations/Jpf.ValidateCustomRule.html> "
annotation, and if so, on which property (seen as how this validation
rule involves two properties)?
Ben
**************************************************************
This message, including any attachments, contains confidential information
intended for a specific individual and purpose, and is protected by law. If
you are not the intended recipient, please contact sender immediately by reply
e-mail and destroy all copies. You are hereby notified that any disclosure,
copying, or distribution of this message, or the taking of any action based on
it, is strictly prohibited.
TIAA-CREF
**************************************************************