• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Struts: No getter method for property name problem

 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Am using Struts.
jsp trace looks like this..
Struts: No getter method for property name of bean org.apache.struts.taglib.html.BEAN
This is the error am getting while rendering the page. I find it amusing. I have the form class with a getter and setter for properties
name,
country.
In the action class,
I fill up the Form class and set it against the mapping.getAttribute() String in the request.
Am not sure why its not able to find the getters by reflection.
Any help w'd be of great help to me
thanks.
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karthik,
it's not necessarily anything to do with your formbean. It could be that you have not specified the name attribute on some <bean: tag. Try reducing the HTML page to the bare minimum that causes this error and then post it here (please don't post loads of html).
Adam
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you sure your getter is spelt getName() , getCountry() ?
thats what my problem was last time i saw that error
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I'm also new to Struts.So was experimenting with the stuffs. I also coem across the same problem. I'm attaching the html code and my Actionbean. CAn anybody help?
HTML
===========================
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<% System.out.println("inside Form"); %>
dshjfasdkhfasdkljfhasdkjfhasdfkjhasdk
<html:html>
<body>
<html:form action="/save.do?Page=1">
<table>
<tr>
<td>username</td>
<td><html:text property="UserName" size="16" /></td>
</tr>
<tr>
<td>password</td>
<td><html:text property="PassWord" size="16" value="" /></td>
</tr>
<tr>
<td colspan=2>
<html:submit/>


</td>
</tr>
</table>
</html:form>
</body>
</html:html>
===============================
Bean
================================
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class MyActionFormBean extends ActionForm{
private String UserName;
private String PassWord;
static{
System.out.println("Inside bean");
}
public void setUserName(String un){
System.out.println("Inside setusername");
this.UserName=un;
}
public String getUserName(){
System.out.println("Inside getusername");
return UserName;
}
public void setPassWord(String pw){
this.PassWord=pw;
}
public String getPassWord(){
return PassWord;
}
}
========================
 
mister krabs
Posts: 13974
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try changing the properties to start with a lower case instead of upper case. "username" instead of "UserName".
<td><html:text property="userName" size="16" /></td>
</tr>
<tr>
<td>password</td>
<td><html:text property="passWord" size="16" value="" /></td>
 
Prasad P Nair
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey...
It's working fine by changing to userName and passWord. Any idea why it is so??
Anyway thanks a lot...3 days i was behind this problem
Cheers
Prasad
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason is that application servers are totally case-sensitive and also have to conform to Sun�s JavaBean specification.
So when the application server reads a JSP and sees a reference to a property on a bean, it will capitalize the first letter of the property name and append �get� or �set� to the front:
<html:text property="passWord" size="16" value="" />
myBean.getPassWord()
myBean.setPassWord()
Now you capitalized the first letter of the property in your HTML tag. That's not meant to be. The effect is probably undefined by the Javabean specification.
Adam
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I keep getting this error.
No getter method for property username of bean org.apache.struts.taglib.html.Bean
I did read all the comments on Case sensitive name and have made sure that i follow the rules. But i still get the same error. Here is my clip of code. Please help. I have spend enuf time on this and cant think of anything else.
//************ Java Bean
public final class WizSearchForm extends ActionForm {
private String action = "WizardSearch";
private String username = null;
public String getAction()
{
return (this.action);
}
public void setAction(String action)
{
this.action = action;
}
public String getUsername() {
return (this.username);
}
public void setUsername(String username) {
this.username = username;
}
// ************ JSP Form
<td align="right">
<bean:message key="prompt.username"/>
</td>
<td><html:text property="username" size="16" /></td>
 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dolly
Your code looks absolutely fine to me.
Just change this part of code from

to

and check your declaration of the corresponding phrase i.e 'prompt.name' in resource.properties file .
Thanks
Ravindra
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have simmilar problem but it is when I am using Vector. my jsp & form bean is like this:
//jsp
<logic:iterate id="itemDesc" name="farmPermitForm" property="itemDetails">
<table>
<TD>
<html:text name="itemDesc" property="qty" styleClass="inputtxt" size="10" maxlength="5" >
<bean:write name="itemDesc" property="qty" />
</html:text>
</TD>
<TD>
<html:text name="itemDesc" property="fa_type" styleClass="inputtxt" size="30" maxlength="30" >
<bean:write name="itemDesc" property="fa_type" />
</html:text>
</TD>
<TD>
<html:text name="itemDesc" property="calibre" styleClass="inputtxt" size="30" maxlength="30">
<bean:write name="itemDesc" property="calibre" />
</html:text>
</TD>
<TD>
<html:text name="itemDesc" property="barrel" styleClass="inputtxt" size="10" maxlength="10" >
<bean:write name="itemDesc" property="barrel" />
</html:text>
</TD>
<TD>
<html:text name="itemDesc" property="overall" styleClass="inputtxt" size="10" maxlength="10" >
<bean:write name="itemDesc" property="overall" />
</html:text>
</TD>
<TD>
<html:text name="itemDesc" property="serial_no" styleClass="inputtxt" size="30" maxlength="30" >
<bean:write name="itemDesc" property="serial_no" />
</html:text>
</TD>

</logic:iterate>
</TABLE>
//
// form bean is :
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
private Vector itemDetails = null;
public class farmPermitForm extends ActionForm {
/**
* Returns the itemDetails.
* @return Vector
*/
public Vector getItemDetails() {
return itemDetails;
}
/**
* Sets the itemDetails.
* @param itemDetails The itemDetails to set
*/
public void setItemDetails(Vector itemDetails) {
this.itemDetails = itemDetails;
}
/**
* Constructor
*/
public FarmPermitForm() {
itemDetails = new Vector();

}
public void reset(ActionMapping mapping, HttpServletRequest request) {
// Reset values are provided as samples only. Change as appropriate.
/*String submitValue = request.getParameter("actionvalue");
System.out.println("ACTION VALUE "+submitValue);
if(submitValue.endsWith("A"))
{

}*/
itemDetails.add(new FAitemDetails());
}
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
// Validate the fields in your form, adding
// adding each error to this.errors as found, e.g.
// if ((field == null) || (field.length() == 0)) {
// errors.add("field", new ActionError("error.field.required"));
// }
return errors;
}

}
/// and the error is like this:
WebGroup E SRVE0026E: [Servlet Error]-[No getter method for property itemDetails of bean farmPermitForm]: javax.servlet.jsp.JspException: No getter method for property itemDetails of bean farmPermitForm
CAN ANY ONE HELP ME WITH THIS PROBLEM.....
THANKS...
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dolly, check your struts.config to make sure you are running the right form.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This seems to be a common problem...
form bean:
public class HVACListFormBean extends ActionForm implements Serializable
private Vector hvaclist = null;
public Vector getHvaclist()
{
return hvaclist;
}
JSP:
<logic:iterate id="appliance" indexId="theIndex" name="hvacListForm" property="hvaclist">
<bean:write name="appliance" property='<%="cdBus["+ theIndex + "]"%>'/>
</logic:iterate>
Error Message: No getter method for property hvaclist of bean hvacListForm
Thanks
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have the same exact problem now and I was wondering if any of you ever got around to fixing that problem. Do you have any suggestions on what is the source of the problem?
Thanks much,
Mete
 
Sheriff
Posts: 17665
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's what you should post to help find the problem:
From struts-config.xml:
- the relevant form definition
- the relevant action mapping
Java code:
- relevant snippets from your ActionForm
JSP:
- relevant snippets, including the <html:form> tag
Cut and paste the stacktrace too.
 
Mete Kural
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank God I could fix the problem by changing the name of the form bean. For some reason the older version of the form bean was getting cached somewhere in the application (I don't know how that could possibly happen, I have no explanations). When I changed the form bean's name, I could add new properties and the jsp page found the getters for those properties. So now it works. I hope this may be helpful for any other who may be having the same problem.
All praise be to God!
Mete
 
Mete Kural
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello again,
Figured out why my problem occurs. It's because somewhere down the line in the request handling, I overwrite the default form bean that is specified in struts-config.xml by another bean that I save in the request scope under the same attribute name, therefore any changes that I made to struts-config.xml did not affect the bean that was in the request scope during the JSP processing. Changing the name of the form bean fixed the problem because the bean that I was saving to the request scope was no more overwriting the default form bean that is specified in struts-config.xml. I had been pondering over this problem over several weeks. Thank God now it is completely resolved.
-Mete
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mete,
this problem bugs me a long time.
Thank you for your infomation.
But I didn't quite follow you.
What form bean is the default form bean?
How did you solve this problem?
Could you give us specific instructions on this?
I believe a lot people are having this problem.
Thanks!
Bruce
 
Mete Kural
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bruce,
By default form bean, I mean the form bean that I specified for that action-mapping in struts-config.xml by setting the name property of the action mapping element to point to the form-bean that I specified under form-beans in struts-config.xml. What I realized was that in my action class I was manually setting another bean in the request scope with the same name as the name I gave to my form-bean in struts-config.xml. So my form bean specified in struts-config was being overwritten by the other bean that I set in the request scope in my action class. For that reason, any changes that I made to my bean specified in struts-config was not being reflected to my JSP page. That is why when I was trying to access new bean properties that I have added in my JSP page I was getting no getter errors, since those new properties are not reflected to the JSP page. I suggest that you check your action classes to make sure you are not overwriting your bean with another bean before it gets to the JSP page.
Please don't hesitate to ask more questions.
May God help you,
Mete
 
Bruce Zhang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Mete for your fast response.
After I posted my question, I solved my NO GETTER problem too.
But ridiculously, I forgot how I solved it.
I remember I only changed the form name in the struts-config.xml, cleared brower cache, and the problem is gone now. I didn't change the code in the action class.
How did you manually set another bean in the request scope with the same name as the name you gave to your form-bean in struts-config.xml? Could you please paste the code for that portion here?
Thanks Mete.
-Bruce
[ September 29, 2003: Message edited by: Bruce Zhang ]
 
Mete Kural
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm happy for you that you were able to fix it. That problem took some of my time too.
>How did you manually set another bean in the request scope with the same name as the name you gave to your form-bean in struts-config.xml? Could you please paste the code for that portion here?
request.setAttribute("registrationForm" registerationBean);
where "registrationForm" is the same as the name property of the form-bean element.
-Mete
 
Bruce Zhang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mete,
It seems that this problem can show up because many causes.
I never used "request.setAttribute("registrationForm" registerationBean);", but still I got the same problem.
The good news for me is that the problem is gone for now.
But I think it will come back for a visit someday. Who knows.
Thanks.
-Bruce
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just another addition to the many already excellent solutions to go round this problem. I just found out that leaving white space at the end of your attributes in the JSP page will cause this error as well.

Hope that helps somebody.

Boniface
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys,

thanks for all the help - it did a great job helping me figure out why i was getting the same error msg.

here's also what helped - i realized that i had a missing <br> tag in my JSP file between another set of radio buttons right above the new ones i'd added.

once i put in this simple tag, it worked like a dream.
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the case sensitivity worked only for the first letter. I guess I was wrong.
I had a attribute called "qAError" with its appropriate getter/setter viz getQAError() and setQAError()

However i kept getting the same error: No getter blah blah blah
Then I just changed my attribute name to "qaError"
Now my getter/setter looked like getQaError() and setQaError()
Everything seems to be working fine now !!!

forget the first letter....it also wants proper case for the second letter

Rule of thumb: define attributes with 1st 2(atleast) letters lower-case.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was having this problem with an attribute on the bean called "inProcess", with getter getInProcess(). I changed the name of the attribute to "interrupted", with getter getInterrupted(), and it works.

So, try using a one-word attribute name if you get this error.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


According to java naming conventions all the variable names and property names shud start with lower letter and the firstletter of the words following shud start with capital letter. So if we follow this we wont get such problem. Coming to beans it creates getter and setter methods by changing the first letter of the property name as capital letter. ex for firstName it creates getFirstName and setFirstName. Here all the letters are lower letters except the first letter from the second word. Here the second word is name so property name as firstName.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Yes we have to follow the conventions specified for java beans
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am alos getting the same error

My JSP
<logic:notEmpty name="timeForm" property="measures">
<logic:iterate name="timeForm" property="measures" id="measure">
<tr>
<td><bean:write name="measure" property="name" filter="true"/></td>
...
</tr>
</logic:iterate>
</logic:notEmpty>


Form code has
Object getMeasures(int index)
Object[] getMeasures()
void setMeasures(Object[] array)
void setMessuares(int index, Object value)

The code works fine in WSAD or Websphere 5.0.1.2

The server m/c 's
JDK version is 1.3, and using Websphere server 5.0.2

Their is no error in console log. the jsp page is processed and forwarded perfectly
But
Error on JSP page.
ServletException in selctcall.do }No
getter method for property measures of bean timeseriesForm

Here measure is an arraylist containing Formbean value objects.

Can any one give any suggestions
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i had the same problem and found out, that its not enough, when the property name start only with one lower letter.

A property name like "bVarName" failed in my application.
After correcting it to two lower letters "baVarName" it worked.

Thats strange to me but who cares. Now it runs.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed property name to lowercase ex: phonenumber
and added get/set method as getPhonenumber and setPhonenumber in my Bean and it works.

I hope this information is helpful.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Juergen Schmitt:
Hi,
i had the same problem and found out, that its not enough, when the property name start only with one lower letter.

A property name like "bVarName" failed in my application.
After correcting it to two lower letters "baVarName" it worked.

Thats strange to me but who cares. Now it runs.



It doesn't work when the property name start only with one lower letter, like your property "bVarName", because one letter can't be consider as a word.

For Dolly Patel, its property is username.
In order to follow the rules, she has to change username in userName, because there is two words.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<TD><bean:write name="myBean" property="myBeanProperty" /></TD>

In this case we expect that struts will call,

myBean.getMyBeanProperty();

by constucting getter method for your property like,

"get" + capitalizeFirstChar(myBeanProperty)

and then calling the resultant method "getMyBeanProperty" on the
bean using reflection.

However it is the other way around,

1) If your bean has a method like "getXXXXXXX" then the property name
you are specifing in JSP should match with the 'internal property'.

You can construct 'internal property' in the following manner.

Struts internally prepares a properties list of 'internal properties'
from the methods in your bean.
The internal property construction is as shown below,


1) Strip off the "get" from the bean getter method.
Now it will become 'XXXXXXX'

2) If first 2 chars of 'XXXXXXX' are chapital letters then
XXXXXXX is the 'internal property'.
otherwise
xXXXXXX is the 'internal propery'.


The property name you are specifing in JSP should match with the
internal propery other wise you will get
"No getter method for property name problem"


General way of specifying getter/setters by following java convensions.


properygetterinternal propery construction
==============================================
namegetNamegetName -> Name -> name

countryNamegetCountryNamegetCountryName -> CountryName -> countryName

fNamegetFNamegetFName -> FName -> FName (since first 2 chars are upper)




<TD><bean:write name="myBean" property="myBeanProperty" /></TD>
In JSP assuming property is the real propery of the bean, we may
specify the following tags,


<TD><bean:write name="myBean" property="name" /></TD>
<TD><bean:write name="myBean" property="countryName" /></TD>
<TD><bean:write name="myBean" property="fName" /></TD>


The first two TD work absolutely fine because the property name we have specified
and the internal property constucted above are exactly same.
But for the 3rd TD the property name and internal property constucted are different.
This is where the problem comes and you wil get the "No getter method for property name"

So make sure that you are giving the internal propery name instead of the
actual bean propery.


Below i have given a simple example of a bean and displaying its properties in the JSP.


JSP
====

<table border=0 cellpadding=0 cellspacing=0>
<logic:iterate id="userDet" type="com.sym.entity.User" name="usersList" scope="session">

<TR>
<TD><bean:write name="userDet" property="FName" /></TD>
<TD><bean:write name="userDet" property="FIRSTNAME" /></TD>
<TD><bean:write name="userDet" property="LName" /></TD>
<TD><bean:write name="userDet" property="login" /></TD>
<TD><bean:write name="userDet" property="email" /></TD>
</TR>

</logic:iterate>
</table>


BEAN
=====

package com.sym.entity;

public class User implements java.io.Serializable {

private static final long serialVersionUID = 4148531659281963091L;

String fName=null;
String lName=null;
String login=null;
String pass=null;
String email=null;
int uId;
String role=null;

public String getFName() {
return fName;
}

public String getFIRSTNAME() {
return fName;
}

public void setFName(String name) {
fName = name;
}
public String getLName() {
return lName;
}
public void setLName(String name) {
lName = name;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getUId() {
return uId;
}
public void setUId(int id) {
uId = id;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}

}



I hope it is clear.
Happy Coding
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,

I'm new working with Struts and also got this "No getter method for property error." Sorry to post the code, but I'm hoping that someone
could tell me what I'm doing wrong. I haven't been able to figure this out and it's not like what was previously mentioned.

The code is as follows:


-- Book.java:

package com.mycompany;

public class Book implements java.io.Serializable {

private static final long serialVersionUID = 1L;

private long id;
private String title;
private String author;
private char available;

public Book() {}

public Book(long id, String title, String author, char available) {
this.id = id;
this.title = title;
this.author = author;
this.available = available;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public char getAvailable() {
return available;
}

public void setAvailable(char available) {
this.available = available;
}
}

============================================================

-- BookListForm.java

package com.mycompany.struts.form;

import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

/**
* MyEclipse Struts
* Creation date: 06-24-2008
*
* XDoclet definition:
* @struts.form name="bookListForm"
*/

public class BookListForm extends ActionForm {

private Collection books;

/**
* @return the books
*/
public Collection getBooks() {
return books;
}

/**
* @param books the books to set
*/
public void setBooks(Collection books) {
this.books = books;
}

public void reset(ActionMapping mapping, HttpServletRequest request) {
books = new ArrayList();
}

}

============================================================

-- BookListAction.java


package com.mycompany.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.mycompany.form.BookListForm;
import com.mycompany.hibernate.*;
import org.hibernate.SessionFactory;
import org.hibernate.Session;
import java.util.Collection;

/**
* MyEclipse Struts
* Creation date: 06-24-2008
*
* XDoclet definition:
* @struts.action path="/bookList" name="bookListForm" input="/jsp/bookList.jsp" scope="request" validate="true"
*/

public class BookListAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse
response) {

BookListForm bookListForm = (BookListForm) form;

SessionFactory factory = null;
Session session = null;
Collection books = null;

try {

factory = HibernateUtil.getSessionFactory();

session = (Session) factory.openSession();

books = session.createQuery("select id, title, author, available from Book t ").list();

bookListForm.setBooks(books);

} finally {
session.close();
}

return mapping.findForward("showList");

}
}

============================================================

-- bookList.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<html>
<head>
<title>Show book list</title>
</head>
<body>
<table border="1">
<tbody>
<%-- set the header --%>
<tr>
<td>Author</td>
<td>Book name</td>
<td>Available</td>
<td> </td>
<td> </td>
</tr>
<%-- check if book exists and display message or iterate over books --%>
<logic:empty name="bookListForm" property="books">
<tr>
<td colspan="5">No books available</td>
</tr>
</logic:empty>
<logic:notEmpty name="bookListForm" property="books">
<logic:iterate name="bookListForm" property="books" id="book">
<tr>
<%-- print out the book information --%>
<td><bean:write name="book" property="author" /></td>
<td><bean:write name="book" property="title" /></td>
<td><html:checkbox disabled="true" name="book" property="available" />
</td>

<%-- print out the edit and delete link for each book --%>
<td><html:link action="bookEdit.do?do=editBook" paramName="book"
paramProperty="id" paramId="id">Edit</html:link></td>
<td><html:link action="bookEdit.do?do=deleteBook" paramName="book"
paramProperty="id" paramId="id">Delete</html:link></td>
</tr>
</logic:iterate>
</logic:notEmpty>

<%-- print out the add link --%>
<tr>
<td colspan="5"><html:link action="bookEdit.do?do=addBook">Add a new book</html:link>
</td>
</tr>

<%-- end interate --%>

</tbody>
</table>
</body>
</html>

============================================================

Sorry for posting the code. Thanks in advance for any help.

Best regards,

Rudi
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,
I also got this same error, "No getter method for property error." when I deploy my Struts 1 application in WebSphere 6.1 but same code works fine with WebSphere 5.1 server. I don't know how to resolve this issuejavascript:%20x(). Any help will be appreciated.

Form Bean
=======
public class TestForm extends ActionForm implements Serializable {

List mileageDetails = new ArrayList();

String actionFlag = null;
public String getActionFlag() {
return actionFlag;
}
public void setActionFlag(String actionFlag) {
this.actionFlag = actionFlag;
}

//The following methods for dynamically populate
public List getMileageDetails() {
return mileageDetails;
}
// non-bean version so as not to confuse struts.
public void populateMileageDetails(List skills) {
mileageDetails.clear();
this.mileageDetails.addAll(skills);
}
public void setMileageDetails(UpdateRowBean skill) {
this.mileageDetails.add(skill);
}
public UpdateRowBean getMileageDetails(int index) {
// automatically grow List size
while (index >= mileageDetails.size()) {
mileageDetails.add(new UpdateRowBean());
}
return (UpdateRowBean)mileageDetails.get(index);

}
}

Action
=========
public class TestAction extends Action{


public ActionForward execute(
ActionMapping aMapping,
ActionForm aForm,
HttpServletRequest aRequest,
HttpServletResponse aResponse
)throws Exception {


ActionForward aAF = null;
TestForm testForm = (TestForm)aForm;
HttpSessionsession = aRequest.getSession();
String actionFlag = testForm.getActionFlag();


if (actionFlag != null && actionFlag.equalsIgnoreCase("send")){
System.out.println(".....hello...."+testForm.getMileageDetails());
testForm.setActionFlag(null);
}else{
List temp = new ArrayList();
for(int i=0;i<10;i++){

UpdateRowBean te = new UpdateRowBean();
te.setJuris("AL"+i);
te.setSupNbr((short)i++);
te.setMileage(i*345);
te.setMileageType("N");
te.setMonth(i);
te.setYear(4);
te.setPerc(0);
temp.add(te);
}
testForm.populateMileageDetails(temp);
}

return aMapping.getInputForward();



}
}

UpdateRowBean
============================
public class UpdateRowBean {
String delFg;
String juris;
long mileage;
String mileageType;
int month;
int year;
double perc;

short supNbr=-1;
String payCheckNbr;
String payCheckM;

//// with getter and setter
}

JSP Page == test.jsp
==========================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
<html:html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Rational Application Developer">
</head>
<body>
<p>Hello Test Page</p>
<html:form action="add_mileage_action_send">
<html:text property="actionFlag" value="send"/>
<table>
<nested:iterate property="mileageDetails" name="DynaMileageForm" indexId="index" >
<tr>
<td><nested:checkbox property="delFg" value="Y" indexed="true" name="mileageDetails"/></td>
<td><nested:text styleId="juris" property="juris" indexed="true" name="mileageDetails" size="2" maxlength="2" /></td>

<td><nested:hidden property="readOnly" indexed="true" name="mileageDetails" />
<nested:text styleId="mileage" property="mileage" indexed="true" name="mileageDetails" size="10" maxlength="10"/></td>
</tr>
</nested:iterate>
<html:submit/>
</table>
</html:form>

</body>
</html:html>

struts - config
===================
<form-bean name="DynaMileageForm" type="celtic.TestForm">
</form-bean>

<action path="/add_mileage_action_send"
type="celtic.TestAction"
name="DynaMileageForm"
scope="request"
validate="true"
input="test.jsp">

<forward name="forward_add_mileage_form" path="test.jsp"></forward>
</action>

I directly call the action from browser and I got the exception.

Thanks,
Subhas
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i am also having the same problem,

No getter method for property: "eid" of bean: "examples.simple.SimpleActionForm"

please help to find the solution.

Thanks.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a getter for "eid".
 
Saravanan Mrajan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Add a getter for "eid".



Thanks


public class SimpleActionForm extends ActionForm {

public String eid = null;


public void reset(ActionMapping mapping, HttpServletRequest request) {

this.eid = null;
}

public String getEid() {
return eid;
}

public void setEid(String eid) {
this.eid = eid;
}
}

this is my code, i have added a getter and setter, but still the problem.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without more information it'll be difficult to help. How are you putting the bean into scope? How are you trying to access the bean?

Please UseCodeTags, and in the future, start a new thread rather than appending on to an old one.
 
Saravanan Mrajan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Without more information it'll be difficult to help. How are you putting the bean into scope? How are you trying to access the bean?

Please UseCodeTags, and in the future, start a new thread rather than appending on to an old one.






struts-config




ProcesssimpleAction.java


i have given all my codes here. please help.

Thanks!!




 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not the JSP.
 
reply
    Bookmark Topic Watch Topic
  • New Topic