This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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.
 
wood burning stoves
 
subject: Strtus and popluating dropdown lists