aspose file tools*
The moose likes Struts and the fly likes Option collections problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Option collections problem" Watch "Option collections problem" New topic
Author

Option collections problem

Gizzmo Zeuzere
Ranch Hand

Joined: May 11, 2001
Posts: 45
Hello!
I have a bean called Student (with name, forname...)
All the students are stored in a database.
But when i return the collection of my students, i dont know how getting the names in my jsp page in order to do a optionscollection.
Can anyone help ?
Thanks !
Norma Caballero
Greenhorn

Joined: Jan 30, 2004
Posts: 27
Hi, if what you want to display is a select with all your students names, you would need to create a collection, for example a list with only the names of the students and then in your jsp you would do something like:

Hope this helps.
Gizzmo Zeuzere
Ranch Hand

Joined: May 11, 2001
Posts: 45
Yes sorry.I 've not noticed that i 've my collection. It's a collection of student beans. And i want to extract only their names and fornames in the select. How can i do that ?
Thanks
Norma Caballero
Greenhorn

Joined: Jan 30, 2004
Posts: 27
Hi
I understand you have a property name and a property forname, separated.
So you would iterate through your beans collection and create a list...for example:

In your formbean you must have a property to set the list and then you would do:

And in your jsp you would do something like the example I gave you on my previous reply.
Hope I made myself clear Good luck!
Norma Caballero
Greenhorn

Joined: Jan 30, 2004
Posts: 27
Sorry I didn't specify something. The iteration an creation of the list should not be done in the jsp, in the jsp you only put the select tag. You could do this in your action class or somewhere else.
Gizzmo Zeuzere
Ranch Hand

Joined: May 11, 2001
Posts: 45
Re hello !
My real problem is not the realisation of the collection.
I've the collection with all my students.
My problem is how to access to an attribute of the collection in the jsp
<html:select .... ?
But Thank for your responses
Norma Caballero
Greenhorn

Joined: Jan 30, 2004
Posts: 27
Hi, I don't understand what you are trying to do.. I would like to help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Option collections problem