Markooo Thomasooo

Greenhorn
+ Follow
since Aug 25, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Markooo Thomasooo

I need to retrieve the info from the AnswerQuestionnaire.jsp into the ProcessQuestionnaire.java
19 years ago
I have a DynaForm that creates a questionnaire from a template stored on the Server.

It now shows fine, but how do I retrieve the selections I have made?

The questions are in a forEach and based on the questionType I show radio button, checkboxes or a text field.

I have attempted storing them in String arrays on the DynaForm, but without luck.


The JSP file looks like this:

<html:form action="/processQuestionnaire" >
<table border="0" width="80%">

<c:forEach var="question" items="${QuestionnaireActionForm.map.questions}">
<tr><td><c ut value="${question.text}"/></td>

<c:forEach var="radio" items="${question.radios}">
<c:if test="${radio != null}">
<tr>
<td><html:radio name="question" indexed="true" property="selectedRadios" value="${radio.id}"/><c ut value="${radio.text}"/></td>
</tr>
</c:if>
</c:forEach>

<c:forEach var="box" items="${question.boxes}">
<c:if test="${box != null}">
<tr>
<td><html:checkbox name="question" indexed="true" property="selectedBoxes" value="${box.id}"/><c ut value="${box.text}"/></td>
</tr>
</c:if>
</c:forEach>

<c:forEach var="text" items="${question.texts}">
<c:if test="${text != null}">
<tr>
<td><html:text name="question" indexed="true" property="selectedTexts" value="${text.text}" maxlength="10" size="10" style="margin-top: 2px; margin-bottom: 5px; border: 1px solid #ffcc99;" /></td>
</tr>
</c:if>
</c:forEach>


</tr>
</c:forEach>
</table>
<P/>
<html:submit value="Update Comments"/>
</html:form>

The struts file looks like this:

<form-bean name="QuestionnaireActionForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="questions" type="dk.procard.eclub.web.model.Question[]"/>
<form-property name="selectedRadios" type="dk.procard.eclub.web.model.Radio[]"/>
<form-property name="selectedBoxes" type="dk.procard.eclub.web.model.Checkbox[]"/>
<form-property name="selectedTexts" type="dk.procard.eclub.web.model.Text[]"/>
</form-bean>

<action path="/setupQuestionnaire"
type="dk.procard.eclub.web.controller.GenerateQuestionnaire"
name="QuestionnaireActionForm"
scope="session"
validate="false">
<forward name="success" path="/AnswerQuestionnaire.jsp"/>
</action>

<action path="/processQuestionnaire"
type="dk.procard.eclub.web.controller.ProcessQuestionnaire"
name="QuestionnaireActionForm"
scope="session"
validate="false">
<forward name="success" path="/questionnaireUpdated.jsp"/>
</action>


The ProcessQuestionnaire file looks like this:

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {

login = (LoginInformationDTO)request.getSession().getAttribute("userinfo");
DynaValidatorForm df = (DynaValidatorForm) form;
Question[] q = (Question[]) df.get("questions");


Radio[] radios = (Radio[])df.get("selectedRadios");
for (int i = 0; i < radios.length; i++) {
log.fatal("radio: " + radios[i].getQuestionId() + ", " + radios[i].getId());
}
Checkbox[] boxes = (Checkbox[])df.get("selectedBoxes");
for (int i = 0; i < boxes.length; i++) {
log.fatal("box: " + boxes[i].getQuestionId() + ", " + boxes[i].getId());
}
Text[] texts = (Text[])df.get("selectedTexts");
for (int i = 0; i < texts.length; i++) {
log.fatal("text: " + texts[i].getQuestionId() + " text: " + texts[i].getText());
}



Thanks for any help.

Mark.
19 years ago