This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

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.
 
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic