• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

indexed html:select in struts

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an <html:select> tag in a struts app (version 1.1-b2) which looks something like this.
<html:select name="useSchedule" property="jobId" indexed="true">
<html ptionCollection name="useSchedule" property="jobList" />
</html:select>
this is embedded in a logic:iterate tag. So my form bean has an ArrayList, each iteration is exposed as useSchedule. Each of these has an arraylist (jobList) and an int (jobId).
The select box works fine, but when I post the form back the jobId field does not get instantiated with the users selection and I can't figure out why.
Any help would be appreciated.
Jesse
<font color="blue">Disabled smilies so code would post properly</font>
[ November 22, 2002: Message edited by: Matthew Phillips ]
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jesse,
when you submit the form, look at the request parameters. What do you see? I presume you see something like this:
useSchedule[0]=31
useSchedule[1]=12
useSchedule[2]=4
That means you've got to have an array of useSchedule beans in existance already in your formbean for Struts to be able to insert the request parameter values at the appropriate index points.
Struts won't create a whole array of them automatically.
You can create the array of the right size by checking what you need in formbean.reset() method, either by looking for the maximum, or by saving the total in a hidden field, etc.
There is also a Struts add-on called nestedbeans that does this automatically. Check on jakarta.
 
Jesse Beaumont
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for that. I couldn't get the html:select working, but the nested tags did the trick.
Jesse
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic