You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sebastian F. Martin" <me...@sebastianmartin.net> on 2003/07/25 21:03:38 UTC

Saving a dynamically created list of radio buttons

Hello,
 
I need to save a dynamically created list of radio buttons to the
database. In order to give the administrator the possibility to give
users roles for certain departments, I am creating a dynamic list of
radio buttons, wich looks like this:
 
Department        No Rights    User Rights    KeyUser Rights
Accounting             o                    o                        o
IT                          o                    o
o
...an so on, where "o" is a radio button.
 
The departments come out of the database, via an ArrayList containing
Key/Value beans, wich I have declared in the ActionForm. To display
them, I use following code:
 
<logic:iterate id="editableRoles"
name='<%=IConstants.USERADMINFORM_KEY%>' property="editableRoles" >
    <html:radio indexed="true" property="value" name="editableRoles"
value="NoRights"><bean:message
key="administration.rights.noRights"/></html:radio>
    <html:radio indexed="true" property="value" name="editableRoles"
value="User"><bean:message
key="administration.rights.user"/></html:radio>
    <html:radio indexed="true" property="value" name="editableRoles"
value="KeyUser"><bean:message
key="administration.rights.keyUser"/></html:radio>
</logic:iterate>
 
This renders following html-code:
<input type="radio" name="editableRoles[0].value" value="NoRights">No
Rights
<input type="radio" name="editableRoles[0].value" value="User"
checked="checked">User
<input type="radio" name="editableRoles[0].value"
value="KeyUser">KeyUser
 
<input type="radio" name="editableRoles[1].value" value="NoRights"
checked="checked">No Rights
<input type="radio" name="editableRoles[1].value" value="User">User
<input type="radio" name="editableRoles[1].value"
value="KeyUser">KeyUser
 
Up to here, everything works fine.
 
To my question:
how do I save this dynamically created list, since I don't know how many
fields to declare in the ActionForm wich, by the way, is of the type
DynaActionForm?
Can I maybe store these fields back in the ArrayList?
 
Thank you very much for your help!
Sebastian