aspose file tools*
The moose likes Other Application Frameworks and the fly likes Query regarding stripes:select in Stripes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Query regarding stripes:select in Stripes." Watch "Query regarding stripes:select in Stripes." New topic
Author

Query regarding stripes:select in Stripes.

pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 413

Hi All,

I have a Student class which consist of set of courses. Now when a student registers , he can register for more than one course at a time, so in jsp I have used <stripes:select> for a select list with courses in options. I want to ask will Stripes populate it in my Student class or I will have to do it manually? And if I will have to do it manually then should I use the standard way to get value from request object or is there any other way in Stripes?


Pawan Chopra
SCJP - DuMmIeS mInD
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Yes, Stripes will populate it in the Student class if you do something like:



GenRocket - Experts at Building Test Data
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 413

Hi,

I have something like this

<stripes:select name="user.courses" size="2" multiple="multiple">
<option value="null"></option>
<option value="java">Java</option>
<option value="qa">QA</option>
<option value="testing">Testing</option>

</stripes:select>


How will I change it according to your example?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

You haven't provided enough information for me to tell you. What is user.courses? A collection of String or a collection of Course objects? If the latter, what are its properties?
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 413

Sorry, I forgot about that, Its a collection of Course objects, it had name and duration properties. Thanks!
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 413

and user.courses is student.courses
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by pawan chopra:
Sorry, I forgot about that, Its a collection of Course objects, it had name and duration properties. Thanks!


Does it have an ID property? Are you saving this stuff in a database? Come on man, get specific. Get detailed. Otherwise, I am just guessing.
pawan chopra
Ranch Hand

Joined: Jan 23, 2008
Posts: 413

I am really really sorry, actually its 2:30 am here and I am almost sleeping . anyways Let me explain you, Student class has a Set<Courses> and I am saving it in database using hibernate ,many to many association, Course class also has a Set<Student>, I am having a table called Student_course_relation, where I am saving a relationship of studentId and courseId. Now when a Student registers for some course or courses I want to save that into the database. So for this First I will be getting the names of courses Student wants to register and then I will fetch the Course from database using those names and will presist it in Student. I don't know whether my approach is right or wrong, but I hope that this time I am not missing anything for you . Let me know If I am still incomplete.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Well, it would have helped to just show the Course class to me. But I'm going to assume it looks something like this:



So you should populate courses in your JSP from the database. You'd could do it one of a few ways. The simplest is to do this in your action bean:



Then in to setup your select list:



${actionBean.courses} will call the getCourses() method. Then you tell it to use the course.id for the value and course.name for the name. When you submit this Stripes will populate each selected course into student.courses as a Course object with the id of the selected option. So assuming you selected course 1 and 3 student would contain 2 courses, one having an id of 1 and the other an id of 3.

If this isn't working for you then you need to show your code and tell us what specifically doesn't work. Error messages, etc. Now get some sleep.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query regarding stripes:select in Stripes.