This question comes up often enough that it probably warrants a short lesson
in JavaBeans.

If a property is named "lastname", the corresponding "getter" should be
named getLastname() and the setter should be named setLastname().  What's
more the parameter type for the "setter" must match the return type of the
"getter".  Please note:  the name of the instance variable used for storing
the lastname property value *is irrelevent*.  The property name is derived
from the names of the "getter & setter" methods alone (, unless you write a
BeanInfo class, in which case, you get to make up your own rules.)  For the
sake of clarity, we often name our instance variables with the same name of
the properties, but this is not required.

For instance:

public class MyForm extends ActionForm{
  private String lastName = null;
  
        public String getLastname(){
           return this.lastName;
        }
  
        public void setLastname( String lastName){
           this.lastName = lastName;
        }
}

is the same as:

public class MyForm extends ActionForm{
  private String someFreakyName = null;
  
        public String getLastname(){
           return this.someFreakyName ;
        }
  
        public void setLastname( String lastName){
           this.someFreakyName = lastName;
        }
}

In both cases, the property name is "lastname", and so the proper tag usage
is <html:text property="lastname"/>.

For reference, see section 8.3 of the JavaBeans specification.
http://java.sun.com/products/javabeans/docs/spec.html

Steve


 -----Original Message-----
 From: Ditlinger, Steve [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, August 19, 2003 11:32 AM
 To: 'Struts Users Mailing List'
 Subject: RE: no getter method found
 
 
 public String getLastname(){....}  Note the capital "L"
 
  -----Original Message-----
  From: Mehran Zonouzi [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, August 19, 2003 6:55 AM
  To: [EMAIL PROTECTED]
  Subject: no getter method found
  
  
  I have the below in my jsp page
  
  Last Name: <html:text property="lastname"/><br>
  
  and this in my ActionForm subclass
  
  private String lastName = null;
  
        public String getlastname(){
           return this.lastName;
        }
  
        public void setlastname( String lastName){
           this.lastName = lastName;
        }
  
  But I keep getting the no gett found error message...
  No getter method for property lastname of bean 
  org.apache.struts.taglib.html.BEAN
  
  
  What should the getter method be called?
  
  
  --
  
  This e-mail may contain confidential and/or privileged 
  information. If you are not the intended recipient (or have 
  received this e-mail in error) please notify the sender 
  immediately and destroy this e-mail. Any unauthorized copying, 
  disclosure or distribution of the material in this e-mail is 
  strictly forbidden.
  
  
  
  ---------------------------------------------------------------------
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
 
 
 ---------------------------------------------------------------------
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to