Struts issue... "No getter method for property..."

G

goa_head

I've seen this problem posted a lot and have recently ran into it.
Trying the various suggestions hasn't worked...

I have an ArrayList which gets put into the Session object by one of
my classes via session.setAttribute. The ArrayList is populated with
various "Forum" objects. I try to iterate through the arraylist with
this on a JSP:

<logic:iterate id="forums" name="forumList">
<tr><td colspan=2><FONT face="Verdana" size="-2">
<b><bean:write name="forums" property="forumName"/></b><br>
</td></tr>
</logic:iterate>

That makes me get the "No getter method for property forumName of bean
forums" error. If I remove the bean:write statement and replace it
with static text, the text gets repeated for the number of items on
the ArrayList, so I *know* it's looping through the objects. It's just
not seeing getForumName().
The arraylist is composed of various "Forum" objects these look like
the following:
------------------------------
public class Forum {

//Variable declarations
private String forumName;

/** Creates a new instance of Forum */
public Forum(String newForumName) {
this.forumName= newForumName;
} //end Forum

public String getForumName() {
return this.forumName;
} //end getForumName

public void setForumName(String newForumName) {
this.forumName = newForumName;
} //end setForumName
} //end class Forum
 
S

Sudsy

goa_head wrote:
<logic:iterate id="forums" name="forumList">
<tr><td colspan=2><FONT face="Verdana" size="-2">
<b><bean:write name="forums" property="forumName"/></b><br>
</td></tr>
</logic:iterate>

While it might not, in fact, be the source of your problem, I
worry about the lack of termination of the <FONT> tag. Your
construct is similar to what I've successfully used in my
production sites.
Do you have the opportunity to debug on the browser side?
If not, can you check your server logs?
Can't suggest more as it appears to be the same as what I'm
using in production...
 
G

goa_head

Sudsy, thanks for the suggestion but properly closing out the font tag
didn't do it :(
The server logs just record the exception text. I appreciate the
response though, at least I know I'm not way of course :)
 
R

Ryan Stewart

goa_head said:
I've seen this problem posted a lot and have recently ran into it.
Trying the various suggestions hasn't worked...

I have an ArrayList which gets put into the Session object by one of
my classes via session.setAttribute. The ArrayList is populated with
various "Forum" objects. I try to iterate through the arraylist with
this on a JSP:

<logic:iterate id="forums" name="forumList">
<tr><td colspan=2><FONT face="Verdana" size="-2">
<b><bean:write name="forums" property="forumName"/></b><br>
</td></tr>
</logic:iterate>

That makes me get the "No getter method for property forumName of bean
forums" error. If I remove the bean:write statement and replace it
with static text, the text gets repeated for the number of items on
the ArrayList, so I *know* it's looping through the objects. It's just
not seeing getForumName().
The arraylist is composed of various "Forum" objects these look like
the following:
------------------------------
public class Forum {

//Variable declarations
private String forumName;

/** Creates a new instance of Forum */
public Forum(String newForumName) {
this.forumName= newForumName;
} //end Forum

public String getForumName() {
return this.forumName;
} //end getForumName

public void setForumName(String newForumName) {
this.forumName = newForumName;
} //end setForumName
} //end class Forum

My first idea is to use JSTL. The Struts designers recommend using the
standard taglib anywhere that the functionality overlaps. In JSTL, that
iterate would be:

<c:forEach var="forums" items="${forumList}">
<tr><td colspan=2><FONT face="Verdana" size="-2">
<b><c:eek:ut value="${forums.forumName}" /></b><br>
</td></tr>
</c:forEach>

My next idea would be to add a close tag for that font tag, followed
immediately by removing the font tag and b tag since they're deprecated. But
this isn't an HTML forum. Other than that I can't help you much. I don't use
logic:iterate for the reason I mentioned above.
 
A

Andrew Thompson

<c:forEach var="forums" items="${forumList}">
<tr><td colspan=2><FONT face="Verdana" size="-2">
<b><c:eek:ut value="${forums.forumName}" /></b><br>
</td></tr>
</c:forEach>

My next idea would be to add a close tag for that font tag, followed
immediately by removing the font tag and b tag since they're deprecated.

...not to mention the redundant <br> tag.

I think that it is a good idea to remove the lot.

Sudsy commented on the <font> tag and the OP
responded to the effect 'tried it - did not work'
but that left me wonderring if they had given
it proper nesting (given the <b> tag as well)
and if incorrect parsing of the HTML might
contribute to the wider problem.

So _my_ recommendation ot the OP is..
see it fail as

.....
<tr><td colspan=2>
<c:eek:ut value="${forums.forumName}" />
</td></tr>
.....

Before you do anything else.

That test should hopefuly rule out the HTML
tags as contributing to it.
..But this isn't an HTML forum.

The effects can the OP wants can be attained
using stylesheets and the EXACT code above..

Check here for further details..
<http://google.com/groups?group=comp.infosystems.www.authoring.stylesheets>

Wonderful things.

[ F'Ups to c.l.j.help ]
 
G

goa_head

OK I'm not sure why, since I didn't change any of the classes, just
the JSPs, but stopping tomcat, clearing out all the classes,
recompiling everything and starting the app server up again made it
work.

WTF! I spent too much time getting this simple thing to work. I guess
I'll have to restart tomcat every time I go do unit testing :(

Thanks for you help again.
 
A

Andrew Thompson

OK I'm not sure why, since I didn't change any of the classes, just
the JSPs, but ....made it work.

I understand there is a setting in the web.xml
that controls how quickly tomcat will respond
to changes.

[ Just as an aside, I am using Apache/Tomcat
under XP with pretty much 'factory installed'
settings and I find it can take as few as a
couple of seconds, and as long as several
minutes, for the 'Start Tomcat' output window
to register a change to a class in WEB-INF. ]
WTF! I spent too much time getting this simple thing to work. I guess
I'll have to restart tomcat every time I go do unit testing :(

You might look into the refresh setting,
but I am afraid it has not been that
important to me, so I have no further
detail to offer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top