aspose file tools*
The moose likes Struts and the fly likes cannot find getter method .... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "cannot find getter method ...." Watch "cannot find getter method ...." New topic

cannot find getter method ....


Joined: Oct 03, 2003
Posts: 2
I have the following:
<logic:iterate name="currentUser" id="tel" property="telephoneNumbers" indexId="index">
<html:text name="tel" property="telephoneNumber" indexed="true" size="20"/>
<html:text name="currentUser" property="telephoneNumbers" size="20"/>
As result, I am getting:
No getter method for property telephoneNumbers of bean tel
I can't figure out which getter/setter and where I need to have. I put indexed getter/setters into the same bean where Vector telephoneNumbers is, for String telephoneNumber. Also, i put getter/setter (same) into Action Form... still same error.
Anybody can provide any hints?
Thanks a million
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
I will tell you that everytime I get that error, when I track it down, I want to kick myself in the pants. I would change the names of your vars to something completely different so that it will be easier to find. When you are trying to find telephoneNumbers and telephoneNumber it can be a pain because they are so close. I'd give that a try.

Joined: Oct 03, 2003
Posts: 2
As far as variables concerned, I don't think I am confused. 'telephoneNumbers' is a vector property - I can get it via html:text... or bean:write
'String telephoneNumber' has indexed getter/setter methods which get/set above-mentioned Vector elements.
The thing is that both 'Vector telephoneNumbers' and 'String telephoneNumber' with all their getter/setter methods are in the same bean object. I also added identical methods into 'ActionForm' class but could set anything for this property, of course, yet.
I can print the Vector property via <bean:write name="tel"/> without 'property' attribute, because it's not a bean. But I need to to iterate over each its vector element and show it in its own, indexed text form field.
However, it looks like <html:text.../> needs a 'property=...' attribute (required!), but what should my "tel" object be in this case? I am using 'telephoneNumber' String property in the same bean object (where 'telephoneNumbers' is found)! Is it gonna work? It doesn't really make sense to create a totally separate bean object just to hold a single phone number to be kept in the Vector 'telephoneNumbers' to be able to use <html:text name="tel" property="telephoneNumber" indexed="true"/>
Could it be that because it's the same bean, I am getting an error about Collection (telephoneNumbers) property (which is accessible otherwise), because <html:text.../> is getting confused?
Bernardus Irmanto

Joined: Oct 03, 2003
Posts: 23
the "name" attribute of logic iterate tag should correspond to your action form (currentUser, in this case, which extends ActionForm). The "property" attribute will corresponds to a collection in your currentUser object.
so somewhere in your currentUser you must have telephoneNumbers variable, which is a collection.
and you must have getter and setter for this variable, which will look like :
public void setTelephoneNumbers(integer index, String number){
(if you want to fill the collection with string object, if not, change accordingly )
public String getTelephoneNumber(index){
return (String)telephoneNumbers.get(index);
<logic:iterate name="currentUser" id="tel" property="telephoneNumbers" indexId="index">

I agree. Here's the link:
subject: cannot find getter method ....