struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thinair <>
Subject [Struts2] dynamic checkbox "list"
Date Tue, 03 Jun 2008 21:20:29 GMT


I spend a lot of time to make a checkbox list work and try the following :

1. <s:iteration + <s:checkbox with a map / and with a list, (IT works well
with texfield !, but not with checkbox), all the code is explain there

2. <s:checkboxlist with a map / list, I didn't put the code , do you have a
working solution ?

For me no solution works!

Could you give me a proper working sample.
My code for <s:iteration + <s:checkbox :

the jsp page :
<s:iterator value="affectMap" status="status">
     <s:textfield name="affectMap[%{#status.index}]"
	value="%{value}" label="%{key}" labelposition="left" />

To load the page I use the following code  (the loading works !):

//build the list with key and value
affectMap.put(key, value); //key = String, value = true (string) or false


To save the result after the user click submit :

int i = affectMap.size(); //size is correct !
Collection test = affectMap.values();

String[] object = null;
for (Iterator iterator = test.iterator(); iterator.hasNext();) {
  object = (String[]);     (ERROR HERE)
  String s = object[0];	


In case I use a texfield, it works !
But in case of a checkbox, I have got at saving an error of type : 
java.lang.String cannot be cast to [Ljava.lang.String;

If I change the String[] to String. The error is the opposite :
[Ljava.lang.String; cannot be cast to java.lang.String

Could you help me ?

thanks in advance,

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message