aspose file tools*
The moose likes Struts and the fly likes html:optionsCollection - Help Needed! 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 "html:optionsCollection - Help Needed!" Watch "html:optionsCollection - Help Needed!" New topic
Author

html:optionsCollection - Help Needed!

Christopher Frankland
Ranch Hand

Joined: Jan 22, 2005
Posts: 42
Hi,

I have spent a few days on this and have finally given in to asking for help. I have a JSP page that contains a combox box that I would like to populate with values coming from my DAO.

I would like to use the html ptionsCollection method to populate the combo box, however, so far I have not been successful at all. Here are the following files and code. Any assistance is really much appreciated Thanks. I am using the following files:

StoreDAO.java
StoreVO.java
LaborManagementForm.java (this is my struts action form)
WelcomeAction.java (portlet action)
Struts-Config.xml
laborManagement.jsp

StoreDAO.java:



StoreVO.java:



LaborManagementForm.java



WelcomeAction.java



Struts-Config.xml



laborManagement.jsp
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The first problem is that while your WelcomeAction apparently gets a list of stores, it doesn't put that list anywhere accessible to the JSP. Since you have a storeList property in your LaborManagementForm, it would make sense to put it there. So, the code in your WelcomeAction should look something like this:

The form variable above refers to the parameter of type ActionForm passed in to the execute() method.

The second problem is that your JSP makes incorrect usage of the htmlptionsCollection tag. Read the heading "OptionsCollection" in this link and you will see where you went wrong. If you code your WelcomeAction as I did above, your JSP would look something like this:

[ June 12, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Christopher Frankland
Ranch Hand

Joined: Jan 22, 2005
Posts: 42
Hi Merrill,

Thank you for your response. I have a decent idea of how this works now, however, I am getting some unusual results in my JSP page. Here is a recap of the code since I updated it. However, in my JSP page, I am only seeing one option within the select combo box. Also, the label is coming back as 'store1', which is not even one of the items in the result set. Any idea what is happening there? There ought to be 25 items appearing in the option list.

Thanks

WelcomeAction.java




laborManagement.jsp



StoreVO.java



GroupInfoDAO.java

Christopher Frankland
Ranch Hand

Joined: Jan 22, 2005
Posts: 42
Resolved, thanks! I changed Collection to ArrayList in my DAO and that did the trick.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:optionsCollection - Help Needed!