Using checkbox in struts out batch delete

Using checkbox in struts out batch delete
JSP

  <html:form StyleId = "delForm" action="/category.do?method=deleteColletion">
      <logic:iterate name="categories" >
         <tr>
            <td<input type="checkbox" name="ids" value="<bean:write name="category" property="id" />">td>
            <td>.....</td>
         </tr>
      </logic:iterate>
    <input type = "checkbox" name="isSelected" value = "true"
                          onclick = "if(delForm.isSelected.checked == true)
                                      {for (var i = 0; i < delForm.ids.length; i ++){delForm.ids[i].checked = true;}}
                                     else{for (var i = 0; i < delForm.ids.length; i ++){delForm.ids[i].checked = false;}}"/>                                              Select all  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    <a href="javascript:if(confirm(' Do you really want to delete the selected column  ?'))delForm.submit()"> Delete all the selected columns  </a>
</html:form>

FormBean (I use DynaActionForm, it is configured in struts-config.xml)

<form-bean name="testingForm"  type="org.apache.struts.action.DynaActionForm">
    <form-property name="id"     type="java.lang.String"/>
    <form-property name="ids"    type="java.lang.Long[]"/>
     ........
  </form-bean> Action
    public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        //  Gets the operation name
        DynaActionForm dyna = (DynaActionForm) form;
        // ids Array is an array of all the selected records the ID value of the
        Long[] ids = (Long[]) dyna.get("ids");
       //  Call the corresponding dao method  , Complete removal of all specified ID action
       return mapping.findForward(".....");
分类:Java 时间:2010-04-01 人气:414
分享到:
blog comments powered by Disqus

相关文章

  • struts-config.xml Xiangjie 2008-08-20

    struts-config.xml is the main Struts configuration file, in which the file, you can configure the data source, form-bean, action, and plug-in (plug-in) and resource files. The main structure of their documents are as follows: <? xml version = "1.0

  • struts-config.xml common configuration Xiangjie (change) 2010-09-08

    The following is a complete struts-config.xml file, see the Notes configuration elements of the instructions. <? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE struts-config PUBLIC "- / / Apache Software Foundation /

  • Detailed struts-config.xml 2010-12-03

    Struts-config.xml to clarify the role of the elements in, for us to build a web project has great benefits. <struts-config> is the root element of struts, which are 8 sub-elements, DTD is defined as follows: <! ELEMENT struts-config (Data-sources

  • struts-config.xml file description element 2010-08-08

    Struts application uses two XML-based configuration files to configure, namely web.xml and struts-cofig.xml file. Web.xml file is the configuration for all web applications, while the struts-config.xml file is struts-specific configuration file, can

  • Struts configuration file struts-config.xml 2010-08-04

    Struts struts-config.xml is the core file, which can be configured to a variety of components. A simple struts-config.xml file <? Xml version = "1.0" encoding = "UTF-8"?> <! DOCTYPE Struts-config PUBLIC "- / / Apache

  • Struts.config.xml configuration Daquan 2010-10-25

    Is the core of Struts struts-config.xml configuration file, in this document describes all the Struts components. Here the main components, including configuration and minor components, is the struts-config.xml contains the following key elements of conte

  • 如何用正则取input type="text"中的value 2014-02-04

    1.如何通过正则取input type="text"中的value呢? 2.如何过滤掉input type="checkbox"的标签? 这样只能达到正则取input type="text"中的value可是不能过滤掉input type="checkbox"的标签! alert [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] alert [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 解决: alert [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

  • 判断多个input type=file是否有已经选择好文件的代码 2014-03-10

    在each中使用return false退出循环,使用return true结束当前次循环,进行下一次循环 表单中有多个<input type="file" name="uploadfile" contentEditable="false" style="width:80%">, 提交表单时需要判断其中至少要有一个input已经选择好文件。 <input type="file" name="uploadfile" contentEditable="false" style="w

  • JS清空上传控件input(type="file")的值的代码第1/2页 2014-04-29

    最近做的一个小功能,需要清空<input type="file">的值,但上传控件<input type="file">的值不能通过JavaScript来修改。 google找到这样一个解决方法: 在上传控件中插入了值,就只能通过form的reset功能来清空了,但是form里面其他的值也被reset了。 既然可以使用form的reset清空,那就有办法了:新建一个临时form,然后将需要清空的上传控件移入其中,reset之后,再移回原来所在位置,最后删除创建的临时for

  • The type java.lang.Object cannot be resolved.It is 2009-10-26

    Thank you for the inaction of Quote 1, The type java.lang.Object cannot be resolved.It is indirectly referenced from required.class files. Information appear to be happening because you installed multiple versions of the relationship between the jre ...

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.357 (s). 12 q(s)