Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic fields in Struts ActionForm?

 
Mallik Avula
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic