Meaningless Drivel is fun!
The moose likes Struts and the fly likes Collections of Objects within an ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Collections of Objects within an ActionForm" Watch "Collections of Objects within an ActionForm" New topic

Collections of Objects within an ActionForm

Bishma Stornelli

Joined: Jan 20, 2012
Posts: 1
Hello. I'll explain my problem in few words.

I need to create a form to make a test from the admin interface. There's only one test. Users must to take the test and all their answers must to be save in the DB.

Questions in the test are all dropdown. They have a description and a set of options. Options have a value and a description. The value of each option is unique within all values (autoincrement id in the database). To save the answer I have to make the bean for the form, so it would be something like a class with UserId and AnswerSet

My classes would look something like this:

public class Question extends ActionForm{
private String description;
private List<Option> options;

public class Option extends ActionForm{
private int value;
private String description;

public class UserTest extends ActionForm{
private int UserId;
private List<Option> answers;

I know how to make the form to the make the test from the user interface. What I don't know is how to make the jsp page to display the needed form and how to get the information in the Action so I can save the users' answers in the model.

It's very importan for me to make this so if you need additional information to answer this topic please ask me and I'll answer as fast as I can.
Vicky Vijay
Ranch Hand

Joined: Apr 23, 2008
Posts: 125
Hello Bishma,

Please refer this html:optionscollection

after displaying the data,

when the user perform action i.e., clicking the button ---> retrieve the dropdown form property in action
I agree. Here's the link:
subject: Collections of Objects within an ActionForm
jQuery in Action, 3rd edition