wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strtus and popluating dropdown lists" Watch "Strtus and popluating dropdown lists" New topic
Author

Strtus and popluating dropdown lists

scot curtis
Greenhorn

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"/>
</html:select>

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)

Thanks
Scot
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: http://aspose.com/file-tools
 
subject: Strtus and popluating dropdown lists
 
Similar Threads
html:select html:options error, no getter. please help
html:select and html:options
retrieve drop down value
Pre-selecting item in dropdown
how to preselect value in dropdownlist in jsp struts