File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes field validation problems in struts-need help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "field validation problems in struts-need help" Watch "field validation problems in struts-need help" New topic

field validation problems in struts-need help

Santosh Ganapa
Ranch Hand

Joined: Mar 27, 2011
Posts: 31

Error is:-
[ServletException in:CustomerDetailsO.jsp] /CustomerDetailsO.jsp(20,20) Unable to find setter method for attribute: errorKey'

CustomerDetailsO.jsp is:-
<html:form action="/submitCustomerForm">
<table> <tr> <td> User Name </td>
<html:text property="firstName" errorKey="org.apache.struts.action.ERROR" />
<html:errors property="firstName" />
<tr> <td> Password </td>
<html:text property="lastName" errorKey="org.apache.struts.action.ERROR" />
<html:errors property="fastName" />
<tr> <td></td>
<html:submit value="Login" />
</html:form> (Validator Form) is:-

public class CustomerForm extends org.apache.struts.validator.ValidatorForm {
private String firstName;
private String lastName;
……..//getters and setters
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors ();
if (getFirstName() == null || getFirstName().length() < 1) {
errors.add ("firstName", new ActionMessage("error.firstName.required"));
if (getLastName() == null || getLastName().length() < 1) {
errors.add ("lastName", new ActionMessage("error.lastName.required"));
} else if (getLastName().length() < 6) {
errors.add("lastName", new ActionMessage("error.lastName.minlength"));
return errors; } resource bundle file:-

# -- standard errors --
errors.header=<div >
errors.prefix=<font face="Monotype Corsiva" color="Green" >
# -- validator --
errors.invalid={0} is invalid.
errors.maxlength={0} can not be greater than {1} characters.
error.firstName.required = User's First Name is required.
error.lastName.required = Last Name is required.
error.lastName.minlength = Last Name can not be less than 6 characters.
I agree. Here's the link:
subject: field validation problems in struts-need help
It's not a secret anymore!