I have a web page that displays check boxes for user to make multiple selection: [code] <html-el:form action="/message/SelectAndMail"> ...... ...... <td> <html-el:checkbox property="recipients[${status.index}].selected" /> </td> <td> <html-el:hidden property="recipients[${status.index}].emailAddress" /> <c:out value="${recipientBean.emailAddress}" /> </td> ...... ...... </html:el> [/code]
For testing purpose, I made 6 selections of e-mail addresses among all check boxes displayed, Those 6 e-mail addresses are my friends'. Then, the SelectRecipientForm.java extends the ActionForm class. In the ActionForm class, the multiple selection of check boxes by users are supposed to populate a String Array. However, the values of the selected check boxes are not picked up. Here is the code of the SelectRecipientsForm.java: import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; public class selectRecipientsForm extends ActionForm { // Map of RecipientField objects. private Map recipientFieldMap = new HashMap(); private String[] recipients = new String[0]; private String[] selectedEmailAddresses; public RecipientField getRecipients( int index ) { RecipientField recipientField = ( RecipientField ) recipientFieldMap.get( new Integer( index ) ); if ( recipientField == null ) { recipientField = new RecipientField(); recipientFieldMap.put( new Integer( index ), recipientField ); } return recipientField; } public String[] getSelectedEmailAddresses() { List theEmailAddressList = new ArrayList(); Iterator i = recipientFieldMap.values().iterator(); while( i.hasNext() ) { RecipientField recipientField = ( RecipientField ) i.next(); if ( recipientField.isSelected() ) { theEmailAddressList.add( "\"" + recipientField.getEmailAddress() + "\"" ); } } return ( String[] )theEmailAddressList.toArray( new String[theEmailAddressList.size()] ); } public void reset( ActionMapping mapping, HttpServletRequest request) { recipients = new String[0]; selectedEmailAddresses = new String[0]; } } Of course, I have this RecipientField.java: public class RecipientField { private String emailAddress = ""; public String getEmailAddress() { return emailAddress; } public void setEmailAddress( String newValue ) { emailAddress = newValue; } private boolean selected = false; public boolean isSelected() { return selected; } public void setSelected( boolean newValue ) { selected = newValue; } } __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]