Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

struts html:checkbox

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am working on a JSP which uses an action form and <logic:iterate to iterate through the records. Action form looks like this.

public class searchNotifForm extends ActionForm{

ArrayList notifications;

public void setNotifications(ArrayList notifications){
this.notifications = notifications;
}

public ArrayList getNotifications(){
return this.notifications ;
}
}

In JSP I am looping through the list using <logic:iterate> and displaying the records.

<table>
<logic:iterate id="notification" name="searchNotifForm" property="notifications" type="NotificationDisplayObject">
<tr>
<td class="bodyCopy" width="10%" align="center">
<html:ext styleClass="button" name="notification" property="brokerName" />
/td>
<td class="bodyCopy" width="10%" align="center">
<html:checkbox name="notification" property="email"/>
</td>
</logic:iterate>
</table>

The issue is the checkbox does not persist state in the object. Am I missing something here..
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
vidya,
You need to use multibox instead of a checkbox. It returns an String[].

So for your case it would be:
<html:multibox property="email">

And the form:
private String[] email;
and getter and setter for email. You just loop through the String[] to check the values!

hope this helps.

Kushal
 
Uh oh, we're definitely being carded. Here, show him this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic