Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DynaActionForm properties not correctly set with checkboxes

 
Roscoe Padsmith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
This link explains why you were getting index out of bound errors.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic