File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Dynamic fields in Struts ActionForm? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic fields in Struts ActionForm?" Watch "Dynamic fields in Struts ActionForm?" New topic

Dynamic fields in Struts ActionForm?

Mallik Avula
Ranch Hand

Joined: Nov 30, 2006
Posts: 86
HI Friends
i will explain the scenario first
i have a page, in that i need to display questions and options for that question.
questions are dynamic, how many i have in database, i need to display all.
and options for a question also dynamic , means one question may have 2 options and other can have 10 options.

For this i created one Question Bean

options Bean is

in Struts-config.xml

in jsp

but it is throwing Exception

How to say in struts-config.xml that a form-property contains another bean and how to solve this problem.
Could any body explain me please?

Thanks & Regards<br />Mallik Avula<br />SCJP1.4
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The <form-property> element is only used if the bean type is DynaActionForm. Since you're not using DynaActionForm, this element is ignored.

I'd suggest simply defining a property in your ActionForm that is a List of QuestionBeans with corresponding getters and setters. If you plan on creating input fields for each question, you will also need an indexed getter for. Example:

You can then use indexed properties to access each question. For more information on how to use indexed properties, see question 7 of this forum's FAQ.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Dynamic fields in Struts ActionForm?
It's not a secret anymore!