I'll assume you have an iteration in your JSP that goes like this:
<logic:iterate name="yourForm" property="clients" id="client">
...
</logic:iterate>
where "clients" corresponds to your collection of client beans. (ie you
have a method in your form called 'getClients()' that returns a List.)
The id "client" is the name I've made up for the bean that comes into scope
for each iteration (ie it corresponds to an element in the "clients"
collection).
You need another collection in your form to represent the selected clients.
Let's call it 'selectedClients'.
You can then place the following code within the above iterate:
<html:multibox name="yourForm" property="selectedClients"/>
<bean:write name="client" property="emailAddress"/>
</html:multibox>
<bean:write name="client" property="title"/>
<bean:write name="client" property="lastName"/>
You will need the following code in your form to support the property
'selectedClients':
private String[] selectedclients = new String[0];
public String[] getSelectedClients() { return selectedclients; }
public void setSelectedClients(String[] value) { selectedclients =
value; }
And add this to your form's reset method:
selectedclients = new String[0];
The effect of the above is to display a check-box for every client, and
present/collect the correct setting for the check-box.
|---------+---------------------------->
| | Caroline Jen |
| | <[EMAIL PROTECTED]|
| | .com> |
| | |
| | 06/10/2004 03:19 |
| | PM |
| | Please respond to|
| | "Struts Users |
| | Mailing List" |
| | |
|---------+---------------------------->
>--------------------------------------------------------------------------------------------------------------|
|
|
| To: [EMAIL PROTECTED]
|
| cc:
|
| Subject: How To Display Check Boxes in Struts?
|
>--------------------------------------------------------------------------------------------------------------|
I am able to create check boxes using HTML. But, I do
not know how to display check boxes in Struts.
Here is what I plan to do:
I have a JavaBean, which gets its properties populated
through database table query. For example, this
JavaBean has three properties; lastName, title,
emailAddress.
And I have a Collection of such a JavaBean because
there are thousands of people in the database table.
Now, it gets to the JSP web page. I am going to
display a table with four columns:
first column: a check box
second column: Last Name
third column: Title
fourth column: E-Mail Address
If client puts a check mark in a check box, the value
of the emailAddress is passed for processing.
How do I display check boxes from a Collection of JavaBean?
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]