• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

[Struts] How to populate dropdown

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I decided to put this question into a thread of its own to keep things clear.
I now know the jsp part of dropdown lists (static options), but now I want to add dynamic values. I understand this can be done with a collection bean, but how exactly?

I'm using Struts w/ Hibernate and I am able to do simple inserts and retrievals from the database (select * from..).

ComponentService.java contains:

The getComponentList i use in my JSP file to show all the values in my Component table

My Action class is called AddComponent.java and my formbean class is called ComponentForm.java

So where and most importantly how do i make the collection and can I use one of the two methods above in my ComponentService?
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U would create the ArrayList in an Action class ans set it as a request attribute. In ur JSP page, u can use the <html ptions> tag to populate the dropdown. The value of the collection attribute of the tag would be the name of thwe request atribute.
 
Ritchie Warsi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey there, tnx.
I know that can be done that way, but how. I've done this before but not "the struts way":

But now I'm using Struts (organized java classes), Hibernate and wanna put it in a collection.
So does anyone have a example of such a source?
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ritchie W.,

Welcome to JavaRanch. We don't have many rules here, but this is a moderated forum and we do have a strict naming policy. Please re-read this policy and edit your display name in order to comply. Thanks and we look forward to seeing around the 'Ranch.
 
Ritchie Warsi
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*Bump*
Anyone?..
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic