Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

field validation problems in struts-need help

 
Ranch Hand
Posts: 32
Netbeans IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
<td>
<html:text property="firstName" errorKey="org.apache.struts.action.ERROR" />
</td>
<td>
<html:errors property="firstName" />
</td>
</tr>
<tr> <td> Password </td>
<td>
<html:text property="lastName" errorKey="org.apache.struts.action.ERROR" />
</td>
<td>
<html:errors property="fastName" />
</td>
</tr>
<tr> <td></td>
<td>
<html:submit value="Login" />
</td>
<td></td>
</tr>
</table>
</html:form>


CustomerForm.java (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; }
App1Messages.properties resource bundle file:-

# -- standard errors --
errors.header=<div >
errors.prefix=<font face="Monotype Corsiva" color="Green" >
errors.suffix=</font>
errors.footer=</div>
# -- 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.
 
Evil is afoot. But this tiny ad is just an ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic