I can see that the details are straightforward for presenting, controlling, and
reading a single checkbox, or multiple independent checkboxes, but I'm trying
to figure out the proper strategies for presenting a dynamic list of
checkboxes.  In particular, I'm developing an "editUser" page, where part of
the User record is the roles they are in.

I didn't want to hardcode the list of roles in the code, so I created a table
to hold role names (which may eventually have more information than just the
name).

I then created a "UserRoleStatus" class, which contains a role name and a
boolean "enabled" flag.  One of the attributes of the ActionForm is a
collection of these.

In the Action class associated with this form, I get all the role names (from
the table) and all the roles the user is in, and I build the collection of
"UserRoleStatus"es.

In this way, I was able to build the following JSP code to present the
checkboxes, with only the ones the user has being checked:

-------------------
                   <logic:iterate name="editUserForm" property="userRoleStatuses"
                        id="role"
                        type="com.intsoft.sgs.web.forms.UserRoleStatus">
                         <tr>
           <td>
            <html:checkbox indexed="yes" name="role" property="enabled"/>
            <bean:write name="role" property="roleName"/>
           </td>
          </tr>
                        </logic:iterate>
-------------------

It's other details that I'm unsure about.

For instance, I guess that when I use checkboxes, in my ActionForm "reset"
method, I'm supposed to set the boolean properties associated with the
checkboxes to false.  So does that mean I'm supposed to iterate through my
array of "UserRoleStatus" objects, setting the "enabled" property to false?  I
added that code, but I wish I could see an illustration of what really happens
if it's not there.

And then, I'm not quite sure what happens in "SaveUserForm" and
"SaveUserAction", which will be referenced when they click "Save" on this page.
I'll need to see which checkboxes are set and cleared, so I can build a new
list of roles for the User record.  I'm not quite sure how to do this, although
once I get the information, building the roles list is easy.

-- 
===================================================================
David M. Karr          ; Best Consulting
[EMAIL PROTECTED]   ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to