• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

html:optionsCollection - Help Needed!

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 html:optionsCollection 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 ]
 
Christopher Frankland
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Resolved, thanks! I changed Collection to ArrayList in my DAO and that did the trick.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic