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

OAF messageChoice 关联问题

时间:2015-01-26 20:41:57      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:

最近有个需求,就是采购订单的供应商要按照一级和二级来选,一级关联二级,二级关联供应商。之前的一级和二级都是用LovInput做的,现在想要改为messageChoice。如下图:

技术分享

改为:

技术分享

下面给大家介绍下我是如何实现的:

1.页面修改:

Cate1的属性改为messageChoice,如下图配置:

技术分享

 

技术分享

Cate1设置事件:

技术分享

参数:

技术分享

Cate2的属性也改为messageChoice,如下图配置:

技术分享

 

技术分享

设一个无参数的事件,用来刷新用:

技术分享

2.在页面关联的AM中,加入如下两个方法:

 

技术分享
 1 public void msgChoice(String zReqLineId)
 2   {
 3     ZReqLinesVOImpl linesVO = this.getZReqLinesVO();
 4     int rowCount = linesVO.getRowCount(); 
 5     for (int i = 0; i < rowCount; i ++)
 6     {
 7       ZReqLinesVORowImpl linesRow = (ZReqLinesVORowImpl)linesVO.getRowAtRangeIndex(i);
 8 //循环遍历各行
 9       Number primaryKey = linesRow.getZreqLineId();//获取行id
10       if (primaryKey.intValue() == Integer.parseInt(zReqLineId))
11       {
12         String cate1 = (String)linesRow.getCate1();
13         System.out.println("cate1:" + cate1);
14         msgChange(cate1);
15       }
16     }
17     
18   }
19 
20   public void msgChange(String cate1)
21   {
22     ViewObject  vo = this.getCuxPOCategory2LovVO1();
23     String whareString="1=1";
24     whareString = whareString + " and DETL_PID = ‘" + cate1 + "‘";
25     vo.setWhereClause(null);//置空VO中的where条件
26     vo.setWhereClauseParams(null); //置空VO中的where条件
27     vo.setWhereClause(whareString);//赋值拼接的where条件
28     vo.executeQuery();  //执行查询
29   }
View Code

 

3.在页面的CO加入如下代码,通过事件调用AM中的方法:

 

技术分享
1 if("select1".equals(pageContext.getParameter("event")))
2     {
3       String Cate1LineId = pageContext.getParameter("Cate1LineId");//获取fireAction的参数
4       System.out.println("Cate1LineId:" + Cate1LineId);
5       Serializable []params = { Cate1LineId };
6       am.invokeMethod("msgChoice", params);//调用AM方法
7     }
View Code

 

出现的bug:

 

本例不适合多行的情况,当出现多行时,会导致二级的messageChoice各行结果总是按照最后选择的一级关联,(如图)原因是每一行都公用一个VO导致的。如果某位大神看到此文,有解决此bug的方法,请写在评论中,谢谢了。

 技术分享

 

OAF messageChoice 关联问题

标签:

原文地址:http://www.cnblogs.com/joker-zhao/p/4251065.html

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