• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"No getter method for property ..." error

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

I'm getting a "no getter method for property firstName of bean org.apache.struts.taglib.html.BEAN" error while processing the following page:

// createBio.jsp
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tld/struts-nested.tld" prefix="nested" %>

<html:errors />
<html:form action="/viewFullBio.do" focus="firstName">
<html:text property="firstName" />
<html:text property="lastName" />
<html:submit />
</html:form>

The obvious mistake (from reading around) is inappropriate naming of the fields/ accessors and mutators in the ActionForm, here it is:

// BioForm.java
/**
* ActionForm to hold details of Bio (including Employments and Tracks).
*/
public class BioForm extends ActionForm {
// The fields.
private String id;
private String firstName;
private String lastName;
private String gender;
private String ethnicity;
private String role;
private List employments;
private List tracks;
// Accessors & mutators for the fields.
public void setId(String id) {this.id = id;}
public String getId() {return id;}
public void setFirstName(String firstName) {this.firstName = firstName;}
public String getFirstName() {return firstName;}
public void setLastName(String lastName) {this.lastName = lastName;}
public String getLastName() {return lastName;}
public void setGender(String gender) {this.gender = gender;}
public String getGender() {return gender;}
public void setEthnicity(String ethnicity) {this.ethnicity = ethnicity;}
public String getEthnicity() {return ethnicity;}
public void setRole(String role) {this.role = role;}
public String getRole() {return role;}
public void setEmployments(List employments) {this.employments = employments;}
public List getEmployments() {return employments;}
public void setTracks(List tracks) {this.tracks = tracks;}
public List getTracks() {return tracks;}
/**
* Reset the fields.
*/
public void reset() {
id = null;
firstName = null;
lastName = null;
gender = null;
ethnicity = null;
role = null;
employments = null;
tracks = null;
}
/**
* Validate the fields.
*/
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if(firstName == null || firstName.length() < 1) {
errors.add("firstName", new ActionError("error.required"));
}
if(lastName == null || lastName.length() < 1) {
errors.add("lastName", new ActionError("error.required"));
}
return errors;
}
}

Here is the config:

//struts-config.xml
<action
path="/addBio"
type="steel.struts.controller.BioActions"
name="bioForm"
scope="request"
validate="true"
input="createBio.page"
parameter="add">
<forward name="success" path="viewFullBio.page" />
</action>

Any ideas/ suggestions gratefully received!
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your jsp uses viewFullBio.do but your struts-config snippet is for addBio.do.
 
Tony Walters
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the viewFullBio.do page was where the form was being submitted to. Am I missing something?
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi tony

action should be /add... rather than view as stated earlier its not the req from where it comes .i hope u r getting what we mean
 
Tony Walters
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I think its just that I have been missing something. This does now work. Not sure I completely understand it, but will go through it slowly. Thanks for the help!
reply
    Bookmark Topic Watch Topic
  • New Topic