Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Value not returned to form inside logic:iterate

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently, with the referenced code below, the selected value on the page IS NOT being saved on the ActionForm with the property listed. Any ideas as to why? Thanks to all!



<logic:iterate name="ReportListForm" property="reportChosen.groups" id="groups">
<logic:iterate name="groups" property="parms" id="parmValues" >
<c:set var="dataName" value="${parmValues.dataType}" />
<c:if test="${dataName=='multipleSelect'}">
<td>
<html:select indexed="true" size="10" name="parmValues" property="value" multiple="true">

<html ptionsCollection name="parmValues" property="choicesList" />

</html:select>
</td>
</c:if>
</logic:iterate>
</logic:iterate>

terms explained
--------------------------------
ActionForm="ReportListForm"
reportChosen = Report class that stores information
groups = ArrayList property of Group types, property of reportChosen
parms = ArrayList property of Parm types, property of groups
dataType = lets me know which type of html element to created for user input
multipleSelect = identifier for a select list with multiple=true
choicesList = ArrayList of choices (type = LabelValueBeans to populate lists)
------------------------------------

Thanks for your assistance. I am stumped!

JD
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you have a loop within a loop, merely specifying indexed="true" with the <html:select> isn't going to work. With a more complex situation like this you either have to use the <nested> tags or build the indexed property name yourself.

If you use the Struts-el version of the tags, the following should work:



In addition to the above, you must also have indexed getters and setters for your properties. Also, if ReportListForm is in request scope, you will need to read this link carefully and follow its instructions for giving your lists "lazy initialization" behavior.
 
JD Thompson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Merrill,

Once again you have proven your stuff. I followed your advice and created a basic structure like you suggested, and voila!, the values are stored.

Thanks again for your time and clear/concise response!!

JD
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're very welcome. Good luck with your project.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!
i would like to do the exact same thing but i cannot understand the solution!i am new in struts and i know nothing about the Struts-el version of the tags.is <c:set > one of them?how can i achieve the same result with <logic:iterate>?i would like to create a drop down list.i have a List which is filled with values from the database, but now,i dont know how to create the <html:select> with the values of those objects...
could anyone help??
is there any tutorial or site that you know with relevant example code?
any help appreciated!!
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am trying to save values of a select in a form. The select is inside 2 nested logic iterate tags similar to the solution provided below. I tried implementing it the same way but I get the following exception:

Invalid indexed property 'fileNumberBeans[indx.intValue()]' on bean class 'class com.test.OfaForm' Invalid index value 'indx.intValue()''

This is what I have in my JSP:

<logic:iterate id="fileNumberBeans" scope="request" type="com.test.FileBean" name="ofaForm" property="fileNumberBeans" indexId="indx">
<logic:notEmpty name="fileNumberBeans">
<tr>
<td class="TableBorder">
<table id="<bean:write name="fileNumberBeans" />">
<logic:iterate id="offBn" name="fileNumberBeans" type="com.test.OfaSDOBean" property="singleDefBeans" indexId="ix">
<tr>
<td id="<bean:write name="offBn" />" align="left" width="310px" class="TableBorder"> 
<bean:define id="offDetailSelectList" name="offBn" property="offDetailSelectList" type="java.util.ArrayList" />
<html:select styleClass="ListBox" property="fileNumberBeans[indx.intValue()].offBn[ix.intValue()].offDetail" name="ofaForm" size="1" >
<html:options collection="offDetailSelectList" property="value" labelProperty="label" />
</html:select>
</td>
</tr>
</logic:iterate>
</table>
</td>
</tr>

</logic:notEmpty>
</logic:iterate>

Any help on this will be greatly appreciated.

Ritu
 
reply
    Bookmark Topic Watch Topic
  • New Topic