On 5/4/10 10:08 AM, RogerV wrote:
<s:checkboxlist name="selectedroles" list="%{availableroles}"
value="%{preselectedroles}"/>
<input type="checkbox" name="{}" value="ROLE_ADMIN" id="{}-1"/>
<input type="checkbox" name="{}" value="ROLE_USER" id="{}-2"
checked="checked"/>
<input type="checkbox" name="{}" value="ROLE_UBER" id="{}-3"/>
The rendering is a bit odd, which makes me feel I'm still missing
something.
Due to the fact that there are three checkboxes with the right values
and the right pre-selection, we know that the list attribute and the
value attribute of the tag are working as desired. The name clearly
isn't working. I've never used a checkboxlist, and I'm unclear as to
how the values are aggregated on submission into the map you desire, but
this brief documentation seems to jive with my understanding that "name"
is usually just that--the name the input tag will use to submit the
field to the server:
"name false false String The name to set for element"
So if it's looking for a string, let's make sure you're giving it one,
and not the .toString of an empty map that it got from your prepare method:
<s:checkboxlist name="%{'selectedroles'}" list="%{availableroles}"
value="%{preselectedroles}"/>
I must admit I don't understand what you expect this to submit, or how
that should become a map -- there are only one set of values, not
pairs...Even if you get this to render the html I'm guessing that you
expect:
<input type="checkbox" name="selectedroles" value="ROLE_ADMIN"
id="selectedroles-1"/>
<input type="checkbox" name="selectedroles" value="ROLE_USER"
id="selectedroles-2" checked="checked"/>
<input type="checkbox" name="selectedroles" value="ROLE_UBER"
id="selectedroles-3"/>
I don't see how you'd get a map out of that. You could get a String[]
easily, which would be the ROLE_ values that were checked...
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org