I am running into problem when trying to implement checkboxes using Struts
html:checkbox tag in <logic:iterate> tag. The scenario is as follows:

I have a result page that is populated from the database. I used the
<logic:iterator> to iterate through the list of results retrieved from
database matching a search criteria. However, when  display the results in a
table in JSP, I want the ability to do a multiple delete by using checkboxes
to check those records that needed to be deleted. I setup a DeleteForm with
"deleteList" attribute of type String[]. 

DeleteForm:
public class DeleteForm extends ActionForm {

        private String[] deleteList = {};
        
        public String[] getDeleteList() {
                return deleteList;
        }

        /**
         * @param strings
         */
        public void setDeleteList(String[] strings) {
                deleteList = strings;
        }
.. so on..
}


In my SearchAction class, i get the results from database and put them in a
list and the list in the request object and display the results page.

SearchAction class:

        memberList = registration.searchRegistration(inputType, inputText);
        request.setAttribute("searchResults", memberList);

In my DeleteAction class which is executed when I submit the Delete action
after checking the records that I want to delete I retrieve the list:

DeleteAction class:
                        DeleteForm deleteForm = (DeleteForm)form;
                        
                        String[] deletes = deleteForm.getDeleteList(); 


In my JSP, I used the "indexed" attribute as follows hoping to identify the
row where the checkbox is checked, but could not retrieve those values in my
Action class. The problem is I get NullPointerException on the line 

String[] deletes = deleteForm.getDeleteList(); 

in my DeleteAction class sayign DeleteForm is null. I don't understand as I
have them in my config file as request scope. I am not sure if this is
right. How can retrieve the values from check boxes.

Please help. 

Below is my JSP code:

<logic:iterate id="register" name="searchResults"
type="org.acaosa.registration.RegistrationTO">
<tr>
        <td width="5%"><html:checkbox name="deleteForm"
property="deleteList" value="true" indexed="true"></html:checkbox></td>
        <td width="20%"><bean:write name="register" property="firstName"
/></td>
        <td width="20%"><bean:write name="register" property="lastName"
/></td>
        <td width="20%" align="center"><bean:write name="register"
property="phone" /></td>
        <td width="25%"><bean:write name="register" property="email" /></td>
        <td width="10%" align="center"><bean:write name="register"
property="region" /></td>
</tr>
</logic:iterate>


Any suggestions will be appreciated.

Thanks

======================================================================== 
This email message is for the sole use of the intended recipient (s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message. To reply to our email administrator directly, send
an email to [EMAIL PROTECTED] 
Toys "R" Us, Inc.

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

Reply via email to