Hi, One possible workaround that comes in my mind is to have a DataForm for each widget, assemble them into an ArrayList inside the Action class, according to how you want the q/a to appear. When submitting this page (collection of forms), just do the reverse to know the user response to each widget rendered.
Please let us know, your workaround. I guess there can be more brilliant minds who have much greater solutions to this. Thanks and Regards, Thomas Joseph ----- Original Message ----- From: Jakub Milkiewicz To: Struts Users Mailing List Sent: Friday, July 21, 2006 1:34 AM Subject: Re: dynamic checkboxes and radio buttons in one group Hi I think i didn't express clearly in my previous mail. I will try to do it again. In my Configuration file i can have any number of questions, for each question i store question text and some kind of flag to indicate if i should render single checkbox or 2 radio buttons. If i render checkbox then its value is "Yes", if i render 2 radio buttons values are "Yes" or "No". My config file is read in action that prepares me a page with questions. Reading configuration is the only place where i can figure how namy questions i need to present. Cause for each question i can have only one answer (one of the radio buttons selected or checkbox checked) i want to map all answers for questions to a single action form property - let's call it questionAnswers. I do not wanna to have a fixed number of properties indicating answer for question1, answer for question2, answer for question3 ... Please take a look at example: Question1: Do you like struts Answer: YES NO (2 radio buttons) Question2: Do you like yourself Answers: YES (checkbox) Question3: Do you feel like a shower Answers: YES NO (2 radio buttons) Question4: Do you like struts-mailing list Answers: YES (checkbox) Submitt. After the submission button is pressed i would like to have my action form property that conforms to these radiobuttons and checkboxes looks like this ["Yes","Yes",null, null] . It indicates that user selected yes radio button for question1 , chcecked checkbox for question2 and didn't select/check any answer widget for question3 and question4. Obviously after submission form need to be validated. Form can be invalid if for some of these questions answer need to be made. If form is not valid it should be redispalyed and previously selected widgets need to be shown. My action form is stored in session scope. I hope that;s clear and i belive that someone can help me... 2006/7/20, Thomas Joseph <[EMAIL PROTECTED]>: > > You can try to have an ArrayList/HashMap of HasMaps representing the > page/form. Each Hashmap can hold the Question/Answer set. > > Please refer to Mapped Properties for more info > 1. http://struts.apache.org/1.2.9/faqs/indexedprops.html > 2. > http://struts.apache.org/1.2.9/userGuide/building_view.html#indexed > > Pass some flag to decide on wheter to display checkbox or radiobuttons. > Hope this will help. > > Thanks and Regards, > Thomas Joseph > ----- Original Message ----- > From: Jakub Milkiewicz > To: Struts Users Mailing List > Sent: Thursday, July 20, 2006 4:26 PM > Subject: dynamic checkboxes and radio buttons in one group > > > Hi > I have a problem with dynamic form handling. On a page i want to present > a > list of questions. For each question you need to make an answer, but > answer > widgets can be represented as 2 radio buttons or single checkbox. > Initially > all answer widgets should be blank - checkboxes unchecked, radio buttons > unselected. > The problem is that i do not know explicite how many questions i need to > dispaly and what kind of answer i need to present i.e. show a checkbox > or 2 > radiobuttons. Number of questions, text of each question and decision to > show answer widget as 1 checkbox or 2 radiobuttons is read from some > kind of > configuration in action that presents me the page. > I would like to have all these answers stored in my action form mapped > to a > single property as some kind of collection (array or list). Also my > actionform is stored in session scope - i know i need to appropraitely > reset > the form. > I searched on the web and i found to use multibox for a group of > checkboxes. > The problem is that i do not know if i need to present a checkbox or 2 > radiobuttons as single answer widget. > All i would like to get is some kind of collection or array in the > form={"yes",null,null,"yes","no",null} > It means that the answer for question 0, 3, 4 was made but answer > widget > for question 1 , 2, 5 was left blank. > Does someone have any idea?? > >