JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Web Framework » WebWork  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
作者 Re:請教Action type:Chain的訊息傳遞 [Re:酸葡萄]
酸葡萄





發文: 40
積分: 0
於 2015-01-20 04:31 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
原先可以正常Work的寫法,
但無論是存檔或是刪除都要重覆寫
Object [] args = { rwid };
List receiveBody = opReceiveDao.getReceiveBody(args);    
request.put("receiveBody", this.getPageList(receiveBody));

所以想改用action chain

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
        <!-- 顯示資料 -->
    <action name="showReceiveList" class="com.Action.OpReceiveShowAction" method="Receive" >
           <result name="success">/Core/Operater/Receive/Show.jsp</result>     
            <result name="input">/Core/Operater/InnerList.jsp</result>           
        </action>
        
        <!-- 資料存檔 -->
        <action name="opReceiveSave" class="com.Action.OpReceiveSaveAction" >
           <result name="success">/Core/Operater/Receive/Show.jsp</result>     
            <result name="input">/Core/Operater/Receive/Show.jsp</result>           
        </action>
        
        <!-- 資料刪除 -->
        <action name="receiveDelete" class="com.Action.OpReceiveDeleteAction" >
           <result name="success">/Core/Operater/Receive/Show.jsp</result>     
            <result name="input">/Core/Operater/Receive/Show.jsp</result>           
        </action>


顯示資料的Action
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class OpReceiveShowAction extends PageHelper  {
  
  OpReceiveDao opReceiveDao = (OpReceiveDao) context.getBean("opReceiveDao");
 
  private int rwid;
  private String doco;
  private String custno;
  private String assyno;
  
  public String Receive() throws Exception {
    // TODO Auto-generated method stub
    Object [] args = {rwid};    
    List receiveHeader = opReceiveDao.getReceiveHeader(args);  
    if(receiveHeader.size()==1){
      Map map = (Map)receiveHeader.get(0);    
      request.put("receiveHeader", map);
      this.setCustno((String)map.get("CUSTNO"));
    }    
    /*取出該單號中的明細*/
    List receiveBody = opReceiveDao.getReceiveBody(args);  
    request.put("receiveBody", this.getPageList(receiveBody));
    return SUCCESS;
  }  


資料存檔的Action
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
public class OpReceiveSaveAction extends PageHelper{
  
  OpReceiveDao opReceiveDao = (OpReceiveDao) context.getBean("opReceiveDao");
  CartridgeSpecDAO cartridgeSpecDao = (CartridgeSpecDAO) context.getBean("cartridgeSpecDao");
  
  private int rwid;
  private String custno;
  private String doco;
  private String workdate;
  private String opreator;
  private String packboo;
  private String barcode;
  private String assyno;
  private String boxno;
  private int fkrwid;
 
    
  @Override
  public String execute() throws Exception {
    // TODO Auto-generated method stub  
    this.setFkrwid(rwid);
 
    Map properties = cartridgeSpecDao.getCartridgeProperties(barcode);
    //System.out.println("Properties Size: "+ properties.size());
    //將頁面的參數放進Map裡,準備寫入資料表中
    properties.put("FKRWID", this.getFkrwid());
    properties.put("doco".toUpperCase(), this.getDoco());
    properties.put("workdate".toUpperCase(), this.getWorkdate());
    properties.put("opreator".toUpperCase(), this.getOpreator());
    properties.put("boxno".toUpperCase(), this.getBoxno());
    properties.put("packboo".toUpperCase(), this.getPackboo());  
    
    if(!properties.containsKey("ASSYNO")){
      //如果沒有判出型號,就把頁面的型號放進Map裡
      properties.put("ASSYNO", this.getAssyno());
    }else{
      //如果有判出型號,就把頁面的型號更新
      this.setAssyno(properties.get("ASSYNO").toString());      
    }  
    
    int rsc = opReceiveDao.setReceiveBody(properties);

//這段的內容其實就是OpReceiveShowAction 取出該單號中的明細的內容
    Object [] args = { rwid };
    List receiveBody = opReceiveDao.getReceiveBody(args);    
    request.put("receiveBody", this.getPageList(receiveBody));

    
    if(properties.get("BARFORMAT").toString().equals("Z")){      
      this.addActionError("沒有符合的項目!");      
    }else{
      this.addActionMessage( "墨匣代碼 : "+ this.getAssyno());
    }
    return SUCCESS;  
  }


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
959 請教Action type:Chain的訊息傳遞 酸葡萄 3819 2015-01-20 04:17
676 Re:請教Action type:Chain的訊息傳遞 酸葡萄 3744 2015-01-20 04:31
707 Re:請教Action type:Chain的訊息傳遞 酸葡萄 37 2015-01-27 08:52
» JWorld@TW »  Web Framework » WebWork

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8