File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes nested dynamic  properties in an ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "nested dynamic  properties in an ActionForm" Watch "nested dynamic  properties in an ActionForm" New topic

nested dynamic properties in an ActionForm

Albewrt Gore

Joined: Feb 08, 2005
Posts: 4
I have an ActionForm to wrap an quiz.
There are several questions, and every question has a text and a list of possible answers.
I coded that with an indexed property in the ActionForm.
Then every item of the list is a map object that contains 2 keys:
-"text" which contains the text of the question
-"answers" which contains the list of possible answers.
Every answer is a map with 2 keys:
-"text" contains the text of the answer
-"true" contains true or false depending from the answer (if it is correct or not).

Then used nested tag library in my jsp (I used LabelValueBean for the string):

<nested:form action="/actions/teacher/quiz-edit">
<html:hidden property="courseId"/>
<nested:iterate property="questions">
Question:<nested:text property="text.value"/><br>
<nested:iterate property="answers">
Answer:<nested:text property="text.value" /><br>
<html:submit>Add a question</html:submit>

But it works well with the question, but it doesn't work with the answers (tomcat says it doensn't find anybean in question[0].answers[0].text.value), I thought because answers are too much structured?
What is wrong with my approach??
I agree. Here's the link:
subject: nested dynamic properties in an ActionForm
Similar Threads
dynamically generated buttons within nested jsp pages
How do I use struts nested hidden fields
nested indexed properties in struts
trying to use nested tags
Struts - Using Nested Beans