struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heligon Sandra <sandra.heli...@thomson.net>
Subject Select all / Unselect all check-box in a table
Date Wed, 26 Mar 2003 16:39:24 GMT

	I have to implement the following JSP page:

	Id       Name	Select

	1        Toto          [ ]
	2        Tata	  [*]
            3        Tata	  [ ]

	<<select all>>  <<unselect all>> <<edit>> <<load>>

	The JSP page is composed of a table and multiple commands. One of
the column is a check-box column.

	I have defined the following DynaVaildatorForm:

	<form-bean name="myForm" dynamic="true"
type="org.apache.struts.validator.DynaValidatorForm">
    
  		<form-property name="items" type="java.util.ArrayList" />
		<form-property name="selected" type="java.lang.String[]" />
	</form-bean>

	And the code of the JSP is the following:
            
            <html:form action="/MyLookupDispatchAction.do" method="GET">  
	<logic:iterate name="myForm" id="items" property="items"
type="myObjetc.Item">
		<tr bgcolor="#EBEBEB">
		    <td bgcolor="#EBEBEB" width="9%"> 
		        <bean:write name="items" property="id"/>
     		    </td>

                            <td bgcolor="#EBEBEB" width="9%"> 
		        <bean:write name="items" property="name"/>
     		    </td>

		     <td bgcolor="#EBEBEB" width="10%">
   			<html:checkbox name="myForm" property="selected"
value="on"/>		     
		     </td>
	</tr>
	</logic:iterate> 
	
	<table width="100%" border="0" cellpadding="0" cellspacing="0"
bgcolor="#ffffff">
	  <tr>
	    <td align="right" valign="top" width="10%"> 
	      <html:submit><bean:message
key="button.select.all"/></html:submit>&nbsp
	      <html:submit><bean:message
key="button.unselect.all"/></html:submit> 
	    </td>
	  <tr>
	</table>
            </html:form>

	The Action class MyLookupDispatchAction.do

	public class CallLookupDispatchAction extends DispatchAction 
	{
		protected Map getKeyMethodMap() 
		  {
		     Map map = new HashMap();
		     map.put("button.edit","lookupEditConnection");
	
map.put("button.select.all","lookupSelectAllConnection");
	
map.put("button.unselect.all","lookupUnselectAllConnection");
		     return map;   
		  }

		public ActionForward lookupSelectAllConnection(ActionMapping
mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception 
		{
			????
  		}

		public ActionForward
lookupUnselectAllConnection(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception 
		{
			????
  		}
	}

	I know that many messages were exchanged about "Multiple submit" but
it is not obvious to understand the best choice.

	For the buttons SelectAll /  unselect all I am not certain that is
the LookupDispatchAction is the best way of making. 
	Perhaps it is necessary to do everything on the client side and not
call the web server, is it the case ?
	To select all or unselect all the check-box of the JSP page do I
have to call a method like 
	BeanUtils.setProperty(form, "selected", ...);
	How can I know the number of records of my form ?
	If someone has a example of a such application, thanks a lot to send
it.
	Sandra
 




----------------------------------------------------------------------------

As of February 12th, 2003 Thomson unifies its email addresses on a worldwide
basis. 
Please note my new email address: sandra.heligon@thomson.net 

http://www.thomson.net/ 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message