Hi,

 

I am currently working on an application which uses Indexed properties.
And I am not able to update the indexed bean properties properly. I have
included some code snippets here.. The problem is when the check box on
the jsp is checked it update correctly, but when the check box is uncked
and saved it fails to update the bean property. Any help on this much
appreciated.

 

Thanks,

Vidya

 

Action form has a Collection of bean objects like this.

 

public class NotificationsActionForm extends ActionForm {

 

    private List notifications = new ArrayList();

 

    //get and set methods are included in the code

 

    public NotificationBean getNotification(int index) {

return (NotificationBean) notifications.get(index);

    }

}

 

And the bean class looks like this..

 

public class NotificationBean {

    private String name;

    private int notificationId;

    private boolean print;

    private boolean email;

    private boolean sms;

 

    // get and set methods included in the code 

}

 

In my jsp I am using check boxes for the Boolean variables. JSP code
looks like this..

 

<html:form action="/saveNotifications.do" method="POST">

  <table>

    <tr>

      <td align="center">Id</td>

      <td align="center">Name</td>

      <td align="center">Email</td>

      <td align="center">Print</td>

      <td align="center">SMS</td>

    </tr>

    <logic:iterate id="notifications" name="notifForm"
property="notifications" type="checkboxes.NotificationBean"
indexId="ctr">

      <tr>

        <td align="center">

          <bean:write name="notifications" property="notificationId"/>

        </td>

        <td align="center">

          <bean:write name="notifications" property="name"/>

        </td>

        <td align="center">

          <html:checkbox property='<%= "notifications[" + ctr +
"].email"%>'/>

        </td>

        <td align="center">

          <html:checkbox property='<%= "notifications[" + ctr +
"].print"%>'/>

        </td>

        <td align="center">

          <html:checkbox property='<%= "notifications[" + ctr +
"].sms"%>'/>

        </td>

      </tr>

    </logic:iterate>

    <tr>

      <html:submit value="Save"/>

    </tr>

  </table>

</html:form>


This message and any attachments are confidential and intended solely for the 
addressee. If you have received this message in error, please notify Discovery 
immediately, telephone number +27 11 529 2888. Any unauthorised use; alteration 
or dissemination of the contents of this email is strictly prohibited. In no 
event will Discovery or the sender be liable in any manner whatsoever to any 
person for any loss or any direct, indirect, special or consequential damages 
arising from use of this email or any linked website, including, without 
limitation, from any lost profits, business interruption, loss of programmes or 
other data that may be stored on any information handling system or otherwise 
from any assurance that this email is virus free even if Discovery is expressly 
advised of the possibility of such damages. Discovery is an Authorised 
Financial Services Provider.

Reply via email to