I have implemented model driven validation in my application but the validation does not work with following warning.
WARNING: The visited object is null, VisitorValidator will not be able to handle validation properly. Please make sure the visited object is not null for VisitorValidator to function properly
Any idea why?
Here is my Action class.
package actions;
import beans.CarListing;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
public class ListCarAction extends ActionSupport implements ModelDriven{
public String execute() {
System.out.println("ListCarAction x" + carListing.getUrl());
return SUCCESS;
}
private CarListing carListing = new CarListing();
public Object getModel() {
return carListing;
}
}
Here is my ListCarAction-validation.xml
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
<validators>
<field name="model">
<field-validator type="visitor">
<param name="appendPrefix">false</param>
<message>Car Listing: </message>
</field-validator>
</field>
</validators>
And here is the bean validator XML named CarListing-validation.xml.
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd">
<validators>
<field name="url">
<field-validator type="requiredstring">
<message>URL is required field.</message>
</field-validator>
<field-validator type="stringlength">
<param name="minLength">1</param>
<param name="minLength">30</param>
<message>The URL must be at least 1-30 characters.</message>
</field-validator>
</field>
</validators>