<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    真善美

    勇于承擔責任; 如果你做不到,要提前跟別人說明,不要等到事情發生后再解釋。

      BlogJava :: 首頁 ::  :: 聯系 :: 聚合  :: 管理 ::
      55 隨筆 :: 0 文章 :: 29 評論 :: 0 Trackbacks

    jsp頁面如下:
    <html>
     <head>
      <title>jsp</title>
     <script type="text/javascript">
      var countline =1;
      /**
      *添加一行
      */
         function addRow(){
       var oldtr=tb.firstChild;
       var tr=oldtr.cloneNode(true);
       tb.appendChild(tr);
       countline++;
      }
      /**
      *刪除一行
      */
       function delrow(row){
        if(countline>1){
        if(confirm("確定刪除此信息?")){
         var tr=row.parentElement.parentElement;
         var index=tr.rowIndex;
         tb.deleteRow(index-1);
        }else{
         return false;
        }
        }else{
         alert("不能刪除最后一行!");
        }
        countline--;
      } 
       </script>
     </head>
     <body>
      <html:form action="/trainInsertAction.do?method=add" method="post">
       <table width="80%" border="1" id="table1" cellspacing="0" cellpadding="0" align="center">
        <tr>     
         <th nowrap>站序</th>     
         <th nowrap>車站</th>          
         <th nowrap>到時</th> 
         <th nowrap>發時</th> 
         <th nowrap>里程</th>
         <th nowrap>歷時</th>
         <th nowrap>硬座</th>
         <th nowrap>軟座</th>
         <th nowrap>硬臥</th>
         <th nowrap>軟臥</th>
         <th nowrap>操作</th>
        </tr>
        <tbody id="tb">
         <TR> 
          <TD><bean:write name="trainInsertForm" property="xh"/></TD>     
          <TD><html:text name="trainInsertForm" property="stationname" title="車站" size="12" value="" />
          </TD>
          <TD><html:text name="trainInsertForm" property="narrivetime" title="到時" size="10" value=""/></TD>
          <TD><html:text name="trainInsertForm" property="nstarttime" title="發時" size="10" value=""/></TD>     
          <TD><html:text name="trainInsertForm" property="distance" title="里程" size="10" value=""/></TD>
          <TD><html:text name="trainInsertForm" property="passtime" title="歷時" size="14" value="0天0小時0分"/></TD>
          <TD><html:text name="trainInsertForm" property="hardseat" title="硬座" size="5" value=""/></TD>
          <TD><html:text name="trainInsertForm" property="softseat" title="軟座" size="5" value=""/></TD>     
          <TD><html:text name="trainInsertForm" property="hardsleeper" title="硬臥" size="5" value=""/></TD>
          <TD><html:text name="trainInsertForm" property="softsleeper" title="軟臥" size="5" value=""/></TD>
          <td> 
           <a href="#delete" onclick="delrow(this);return false">刪除</a>  
          </td>
         </TR>
        </tbody>
        <tr>      
         <td nowrap colspan="11" align="right">
          <a href="#add" onclick="addRow();return false;">添加 </a>
         </td>      
        </tr>
        <tr>      
         <td align="center" colspan="11">
          <html:button property="button"  value=" 保存 " onclick="toCheck()"/>
         </td>      
        </tr>
       </table>
      </html:form>
     </body>
    </html>

     form:
    上面寫的jsp實現多行提交原理,在form中把PO的所有屬性定義為數組的形式,然后再寫一個 方法調用PO的full constructor方法,封裝成一個新的list,返回。
    public class TrainInsertForm extends BaseForm {
     private static final long serialVersionUID = 1L;
     protected static TrainService trainService;
     private String[] xh;
     private Long[] nid;
     private String[] narrivetime;
    ...............................(其他屬性和get,set方法略)
     public List<Trainnode> makeTrainNodeListAdd() {
      int length = hardseat.length;
      List<Trainnode> list = new ArrayList<Trainnode>();
        for (int i = 0; i < length; i++) {
        Trainnode trainnode = new Trainnode(new TrainnodeId(), nd
         .getNid(), nid[i], nstarttime[i], distance[i],
         hardseat[i], softseat[i], hardsleeper[i],
         softsleeper[i], passtime[i]);
       list.add(trainnode);
      }
      return list;
     }
    PO類:
    ...............
     /** full constructor */
     public Trainnode(TrainnodeId id, Long nid, String narrivetime,
       String nstarttime, Integer distance, Float hardseat,
       Float softseat, Float hardsleeper, Float softsleeper,
       String passtime) {
    .........
     }

    posted on 2009-03-11 15:08 真善美 閱讀(276) 評論(0)  編輯  收藏 所屬分類: Java學習
    主站蜘蛛池模板: 成人福利免费视频| 亚洲AV无码乱码在线观看性色扶| 亚洲成人激情小说| 亚洲片国产一区一级在线观看| 久久福利青草精品资源站免费| 亚洲人xxx日本人18| 久久久久亚洲AV综合波多野结衣| aⅴ在线免费观看| 一个人晚上在线观看的免费视频 | 亚洲AV成人潮喷综合网| 久久久久久成人毛片免费看 | 免费观看激色视频网站bd| 边摸边吃奶边做爽免费视频网站| 亚洲va在线va天堂va888www| 免费一级毛片免费播放| 最近中文字幕高清免费中文字幕mv| 国产精品亚洲五月天高清| 亚洲日本在线观看网址| 国产亚洲日韩在线三区| 男女啪啪永久免费观看网站| 99久久久国产精品免费蜜臀| 成人久久久观看免费毛片| 亚洲欧洲免费无码| 337p欧洲亚洲大胆艺术| 久久精品国产亚洲5555| 韩国免费三片在线视频| 4455永久在线观免费看| 国产免费一区二区三区不卡 | 香蕉视频在线免费看| 亚洲女子高潮不断爆白浆| 亚洲人成电影福利在线播放 | 阿v免费在线观看| 亚洲熟妇AV乱码在线观看| 18gay台湾男同亚洲男同| 亚洲国产无套无码av电影| www.亚洲色图.com| 麻豆国产精品入口免费观看| 四虎永久在线观看免费网站网址 | 嫖丰满老熟妇AAAA片免费看| 日本卡1卡2卡三卡免费| 国产成人无码免费看片软件 |