• 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

DynaActionForm properties not correctly set with checkboxes

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

What I'm trying to do is fill the property "choice" (String[]) of different "CopyVacationForm"s. What I have is a CopyVacationsForm which is a DynaActionForm containing a CopyVacationForm[] property cvfs.

My form bean has the correct getters and I'm not getting any errors but when I submit it it's not filled with the values I wanted.


In my jsp I do :




In my Struts-config.xml I have :



Other values of the form beans are correctly set but dealing with checkboxes and String arrays seems to be a problem.

Any help or suggestion would be really appreciated.
Thanks in advance.

-- Alain
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add indexed="true" to your html-el:checkbox tag and change the name attribute from cvf to cvfs.
[ June 11, 2008: Message edited by: Merrill Higginson ]
 
Roscoe Padsmith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for answering so quickly.

I already tried using indexed properties but I got an out of bounds exception because some of the records (from sitePlanRecords.records) are actually not displayed (yes I tried to clear some of the dark side of my code for better readability ).

I managed to get contents of "choice" using String [] choice = request.getParameterValues("choice") in my Action class but what I get is a big array with all the values (that were checked) in it so i changed the value property of the checkbox with value="${cvf.idEmployee},${record.numDay}". This way I get the matching line (i.e. employee) with some string tokenizing. I know it's a bit dirty but it's the best (actually only) way i could think of.

Don't hesitate if you have better ideas.

Regards,

-- Alain
 
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
This link explains why you were getting index out of bound errors.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic