Hello, I have hopefully an answer and a question for you. first the answer : I got the list of checkboxes working by using the "fieldValvue" attribute of <s:checkbox ... you need to have a setter that gets called from the "name" attribute which takes a String[] argument. this argument will contain all the checkboxes that are set (checked) after the submit.
Now the Question : I am trying to get the textfield list working (in parallel to the check boxes) but couldn't ?? the function I set to be called is never called after the submit. I know that the values in the textfiels are sent, and the setter function for the Checkboxes is called but not the function for the textfields ??? I assument that this setter should have String[] for argument as well ? thank you Christian Wiederseiner wrote: > > hello, > > 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" /> > </s:iterator> > > > > > 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 > (string) > > +getAffectMap/setAffectMap > > > > > 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[]) iterator.next(); (ERROR HERE) > String s = object[0]; > System.out.println(s); > > } > > 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: http://www.nabble.com/-Struts2--dynamic-checkbox-%22list%22-tp17633987p21148600.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org