struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Himanshu Ranavat" <hrana...@xythos.com>
Subject Struts visitorfieldvalidator invoked even when the getter is not invoked
Date Thu, 28 Aug 2008 21:24:25 GMT
Hi,
 
I am using Struts Validation using annotations such as
FieldExpressionValidator and VisitorFieldValidator on the Person Object.
Now the wierd part is even though I do not invoke the getter on the
Person objects, struts starts to validate it. Is this correct behavior.
Shouldn't struts initiate validation only if the Person Object is being
used. The problem this is creating for me in another case is that when
the Person Object is not present, Struts still tries to validate. I know
I can check if the object exists then do validation but I want to
confirm if this is correct behavior and not a bug.....
 
This is my action class with validations:
 
@Validations
public class PersonAction extends ActionSupport {
  private Person person = new Person();
  //VisitorFieldValidator will cause Struts to invoke validations on
Person Obj
  @VisitorFieldValidator(message="")
  public Person getPerson() {
    return person;
  }
  public void setPerson(Person person) {
    this.person = person;
  }
  public String execute() {
    // do processing
    return SUCCESS;
  }
}
 
This is my Person Business Object which uses field validator:
 
@Validation
public class Person {
  
  public boolean isPersonInvalid() {
    return someValue;
  }
  @FieldExpressionValidator(
      message="xyz", key="xyz",
      expression="personInvalid")
 public int getX() { return x;}
 public vod setX(int p_x) {m_x = p_x;}
  
  private int x;
}

The interceptor stack includes ValidationInterceptor for PersonAction
 
Himanshu


This email and any attachments may contain confidential and proprietary
information of Xythos that is for the sole use of the intended
recipient.  If you are not the intended recipient, disclosure, copying,
re-distribution or other use of any of this information is strictly
prohibited.  Please immediately notify the sender and delete this
transmission if you received this email in error.

Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message