码迷,mamicode.com
首页 > 其他好文 > 详细

struts2表单批量提交

时间:2015-09-18 11:40:46      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
<%@ taglib prefix="s"     uri="/struts-tags" %>  
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> 
<%@ taglib prefix="fmt"   uri="http://java.sun.com/jstl/fmt" %>
<%@ page   contentType = "text/html; charset=UTF-8" %> 

<s:form action="dailyDutyListStore" method="post" name="operation" theme="simple">
<table id="DataList">
<tr>
    <th nowrap style="text-align:center;">日期</th>
    <th nowrap style="text-align:center;">值班领导</th>
    <th nowrap style="text-align:center;">当值值班长</th>
    <th nowrap style="text-align:center;">值班警员</th>
    <th nowrap style="text-align:center;">值班警力</th>
</tr>

<s:iterator value="dailyDutys" status="status">
<tr>
    <td nowrap align="center">
        <input type="hidden" name="dailyDutys[<s:property value=‘#status.index‘/>].key" value="<s:property value=‘key‘/>"/>
        <input type="hidden" name="dailyDutys[<s:property value=‘#status.index‘/>].dutyDate" value="<s:date name=‘dutyDate‘ format=‘yyyy-MM-dd‘/>"/>
        <input type="hidden" name="dailyDutys[<s:property value=‘#status.index‘/>].deptName" value="<s:property value=‘deptName‘/>"/>
        <input type="hidden" name="dailyDutys[<s:property value=‘#status.index‘/>].deptType" value="<s:property value=‘deptType‘/>"/>
        
        
        <s:date name="dutyDate" format="yyyy/MM/dd"/>
    </td>
    <td nowrap align="center">
        <input type="text" name="dailyDutys[<s:property value=‘#status.index‘/>].people1" value="<s:property value=‘people1‘/>"/>
    </td>
    <td nowrap align="center">
        <input type="text" name="dailyDutys[<s:property value=‘#status.index‘/>].people2" value="<s:property value=‘people2‘/>"/>
    </td>
    <td nowrap align="center">
        <input type="text" name="dailyDutys[<s:property value=‘#status.index‘/>].people3" value="<s:property value=‘people3‘/>" style="width:400px;"/>
    </td>
    <td nowrap align="center">
        <input type="text" name="dailyDutys[<s:property value=‘#status.index‘/>].dutyNum" value="<fmt:formatNumber value=‘${dutyNum}‘ pattern="#" type="number"/>"/>
    </td>
</tr>
</s:iterator>

</table>
</s:form>

<tiles:insertTemplate template="../../tiles/bars/submitbar.jsp" flush="true"/>

<style>
 .checkboxLabel {
    vertical-align:top;
    width:180px;
    display:inline-block;
    }
    .selectBox {
    border:none;
    }
</style>
/**
     * 保存值班基本信息。根据保存的value对应的key值来区分是创建create还是修改edit
     * 如果key值为空,那就创建;如果key值不为空,那就保存
     * @return forward
     * @throws ParseException 
     */
    public String store()
        throws NamingException, ParseException
    {
        if(this._dailyDutys == null || this._dailyDutys.size() == 0)
        {
            super.addActionError("未找到内容!");
            return ERROR;
        }
        DailyDutyLocal dailyDutyDao = EjbUtil.getDailyDutyLocal();
        for(DailyDuty value : this._dailyDutys)
        {
            if(value == null)
            {
                continue;
            }
            if(StringFactory.isNotNull(value.getKey()))//修改
            {
                DailyDuty theDailyDuty = dailyDutyDao.findDailyDuty(value.getKey());
                theDailyDuty.setValue(value);
                dailyDutyDao.doMerge(theDailyDuty);
            }
            else//新建
            {
                value.setCreateBy(super.getCurrentUser().getName());
                dailyDutyDao.createDailyDuty(value);
            }
        }
        return SUCCESS;
    }

 

struts2表单批量提交

标签:

原文地址:http://www.cnblogs.com/geniussoft/p/4818633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!