File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Strtus and popluating dropdown lists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strtus and popluating dropdown lists" Watch "Strtus and popluating dropdown lists" New topic

Strtus and popluating dropdown lists

scot curtis

Joined: Oct 16, 2008
Posts: 1
For some reason I can't figure out what I am doing wrong when I am pre-populating a select list from a arraylist collection from my form.

My flow is as follows: when a user clicks a link, I call a action class that initializes the arraylists (on the form) from the database. That part is working fine; I am getting the data and populating the labelvalue object just fine and then setting the arraylist with all the labelvalue objects. As far as my jsp goes, this is what I have:

<html:select name="CreateDateForm" property="selectedStatusType">
<html ptions collection="statusTypeList" property="value" labelProperty="label"/>

Now in my form, I have the approiate getters/setters (getStatusTypeList/setStatusTypeList), however, when I load the page, I get the following error:

javax.servlet.ServletException: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean under name statusTypeList

Now, the weird part is that when I add the following line in my action class before I return to the jsp, it works:

request.setAttribute( "statusTypeList", createDataForm.getStatusTypeList() );

Now, can anyone tell me why this is not working without the setAttribute call? I know it is something simple that I am overlooking, but I just can't think of what it is... (as a side note, all data that I have - text fields, are working fine, it is just select lists)

Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
I think your problem is that if you want to get the list from your form you needt to use the name and property attributes of the tag, rather than the collection attribute.
I agree. Here's the link:
subject: Strtus and popluating dropdown lists
It's not a secret anymore!