mnateras
asked on
submit a LIST in struts
Hello Experts,
I'm programming JSP with Apache Struts and I haven't been able to find the way to submit a List property of the form to the next JSP
My case is the following:
I have a JSP (agentInteractions.jsp) where data is modified, this jsp is popoulated with a List property with the following code:
<c:forEach items="${immunizationSched uleForm.ag entInterac tionsList} " var="agentList">
<tr>
<td align="center" class="lightgray">
<html:radio name="agentList" property="interactionAgent Key" value="true"/>
</td>
<td align="left" class="lightgray">
<html:select name="agentList" property="ruleCode">
<html:option value="1"><bean:write name="agentList" property="ruleDesc"/></htm l:option>
</html:select>
</td>
<td align="left" class="lightgray">
<html:select name="agentList" property="ruleCode">
<html:option value="1"><bean:write ame="agentList"property="i nteraction AgentDesc" /></html:o ption>
</html:select>
</td>
<td align="left" class="lightgray">
<html:select name="agentList" property="interval">
<html:option value="1"><bean:write name="agentList" property="interval"/></htm l:option>
</html:select>
<html:select name="agentList" property="intervalUnits">
<html:option value="1"><bean:write name="agentList" property="intervalUnitsDes c"/></html :option>
</html:select>
</td>
</tr>
</c:forEach>
this jsp will go to the corresponding action, but when I get there, data from {immunizationScheduleForm. agentInter actionsLis t is NULL
I already tried to submit this property thru a hidden field (<html:hidden name="immunizationSchedule Form" property="agentInteraction sList " ?> but I get an error
I believe probably there's an special way to submit list property's
Thanks for your help. Urgent
I'm programming JSP with Apache Struts and I haven't been able to find the way to submit a List property of the form to the next JSP
My case is the following:
I have a JSP (agentInteractions.jsp) where data is modified, this jsp is popoulated with a List property with the following code:
<c:forEach items="${immunizationSched
<tr>
<td align="center" class="lightgray">
<html:radio name="agentList" property="interactionAgent
</td>
<td align="left" class="lightgray">
<html:select name="agentList" property="ruleCode">
<html:option value="1"><bean:write name="agentList" property="ruleDesc"/></htm
</html:select>
</td>
<td align="left" class="lightgray">
<html:select name="agentList" property="ruleCode">
<html:option value="1"><bean:write ame="agentList"property="i
</html:select>
</td>
<td align="left" class="lightgray">
<html:select name="agentList" property="interval">
<html:option value="1"><bean:write name="agentList" property="interval"/></htm
</html:select>
<html:select name="agentList" property="intervalUnits">
<html:option value="1"><bean:write name="agentList" property="intervalUnitsDes
</html:select>
</td>
</tr>
</c:forEach>
this jsp will go to the corresponding action, but when I get there, data from {immunizationScheduleForm.
I already tried to submit this property thru a hidden field (<html:hidden name="immunizationSchedule
I believe probably there's an special way to submit list property's
Thanks for your help. Urgent
ASKER
Thanks, I have found out a way to do it
for Each field in the List, I mapped a corresponding String[] property in the FormBean
ex:
List listVar;
imagine list with 2 fields: field1, field2
we add the following propertys in the FormBean (ActionForm)
String[] listField1
String[] listField2
on the .jsp I mapped the fields
<c:forEach items="${formBean.listVar} " var="listName">
<html:select name="FormBean" property="listField1">
......
<html:select name="FormBean" property="listField2">
.......
And I get those arrarys populated with all the <select> values in the Action Class
Regards,
for Each field in the List, I mapped a corresponding String[] property in the FormBean
ex:
List listVar;
imagine list with 2 fields: field1, field2
we add the following propertys in the FormBean (ActionForm)
String[] listField1
String[] listField2
on the .jsp I mapped the fields
<c:forEach items="${formBean.listVar}
<html:select name="FormBean" property="listField1">
......
<html:select name="FormBean" property="listField2">
.......
And I get those arrarys populated with all the <select> values in the Action Class
Regards,
Glad that you solved it by your own.
Shall I ask the page editor to remove this question and refund the points back to you?
David
Shall I ask the page editor to remove this question and refund the points back to you?
David
ASKER
I have antoher issue regarding this same matter.
I have succesfully send all the values selected to the corresponding action.
Now I've been strugling populating the <html:select> with the corresponding values retrieved.
The situation is as follows:
I have all the values set in the corresponding arrays, which are
* scheduleAgentKey
* interactionAgentKey
My jsp is as follows
<c:forEach items="${immunizationSched uleForm.ag entInterac tionsList} " var="agentList">
<tr>
<td align="left" class="lightgray">
<c:out value='${agentList.schedul eAgentKey} ' />
<html:select name="immunizationSchedule Form" property="scheduleAgentKey " value="">
<html:option value="1">scheduleAgent 1</html:option>
<html:option value="2">scheduleAgent 2</html:option
</html:select>
</td>
<td align="left" class="lightgray">
<html:select name="immunizationSchedule Form" property="ruleCode">
<html:option value="1">ruleCode 1</html:option>
<html:option value="2">ruleCode 2</html:option>
</html:select>
</td>
</c:forEach
I have found out that if i'm able to put the value I want to be selected in the <html:select value="valueToBeSelected"> it will work, but know the problem is:
HOW do I escape the value of agentList.scheduleAgentKey to this value property?
I already tried this
<html:select name="immunizationSchedule Form" property="scheduleAgentKey " value="${agentList.schedul eAgentKey} ">
And values were no selected properly (it just select the default value)
I already <c:out value="${agentList.schedul eAgentKey} "/> and the value is printed, but some how is not escaped in the select tag
Please help!!!
I have succesfully send all the values selected to the corresponding action.
Now I've been strugling populating the <html:select> with the corresponding values retrieved.
The situation is as follows:
I have all the values set in the corresponding arrays, which are
* scheduleAgentKey
* interactionAgentKey
My jsp is as follows
<c:forEach items="${immunizationSched
<tr>
<td align="left" class="lightgray">
<c:out value='${agentList.schedul
<html:select name="immunizationSchedule
<html:option value="1">scheduleAgent 1</html:option>
<html:option value="2">scheduleAgent 2</html:option
</html:select>
</td>
<td align="left" class="lightgray">
<html:select name="immunizationSchedule
<html:option value="1">ruleCode 1</html:option>
<html:option value="2">ruleCode 2</html:option>
</html:select>
</td>
</c:forEach
I have found out that if i'm able to put the value I want to be selected in the <html:select value="valueToBeSelected">
HOW do I escape the value of agentList.scheduleAgentKey
I already tried this
<html:select name="immunizationSchedule
And values were no selected properly (it just select the default value)
I already <c:out value="${agentList.schedul
Please help!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Additionally, you are naming all the select boxes with the same name i.e. agentList.
<html:select name="agentList" property="interval">
<html:option value="1"><bean:write name="agentList" property="interval"/></htm
</html:select>
<html:select name="agentList" property="intervalUnits">
<html:option value="1"><bean:write name="agentList" property="intervalUnitsDes
</html:select>
David