Results 1 to 2 of 2
- 04-07-2012, 07:49 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 1
- Rep Power
- 0
dynamic radio buttons using struts logic iterate
Hi,
I have list of questions and list of choices mapped to each question. I want to display the questions and choices in the jsp with choices being radio buttons. I am calling an external service and I am getting response with any number of questions or choices.
I have the created beans for Question and Choice.
Code Strutcure is as follows:
Java Code:public class ResponseForm extends ActionForm{ private List questions; // public void setQuestions(List questions){ this.questions = questions; } public List getQuestions(){ return questions; } }Java Code:public class Question{ private List choices; public void setChoices(List choices){ this.choices = choices; } public List getChoices(){ return choices } }We were able to display the radio buttons in the screen but when selecting the choice we are not sure how to map it back to bean objectsJava Code:public class ChoiceOption{ private String choiceOption; public void setChoiceOption(String choiceOption){ this.choiceOption = choiceOpiton; } public String setChoiceOption(){ return choiceOpiton; }
Please help me on how to map the data with the forms after selecting and submittingJavaScript Code:<logic:iterate name="questionsList" id="data" scope="session" type="check.Question"> <bean:define id="choiceList" name="data" property="choices" ></bean:define><br> <logic:iterate id="choi" name="choiceList" indexId="j" type="check.Choice" > <%String choOption = choi.getChoiceOption(); String questionID = "Question"+data.getQuestionID(); %> <tr> <td valign="top" align="left" class="urTxtStd"> <bean:define id="choiceID" name="choi" type="check.Choice" ></bean:define> <input type="radio" name="<%=questionID%>" value="<%=choOption%>" onclick="setSelection('<%=questionID%>');"></input> <bean:write name="choiceID" property="choiceOption" ignore="true" /> <br> <td> </tr> </logic:iterate> </logic:iterate>Last edited by shariprasad83; 04-07-2012 at 09:45 AM.
- 04-07-2012, 08:02 AM #2
Similar Threads
-
Help help.radio buttons
By 10e5x in forum New To JavaReplies: 3Last Post: 01-04-2011, 07:10 PM -
The TagExtraInfo class for logic: iterate was not found on classpath
By snkfororg in forum EclipseReplies: 0Last Post: 07-13-2010, 06:25 PM -
problem with <logic:iterate> tag looping
By tsaswathy in forum Web FrameworksReplies: 0Last Post: 09-27-2008, 12:13 PM -
How to use Radio Buttons
By Java Tip in forum SWTReplies: 0Last Post: 07-25-2008, 02:26 PM -
iterate HashMap with logic
By Heather in forum Web FrameworksReplies: 2Last Post: 07-03-2007, 09:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks