始创于2000年 股票代码:831685
咨询热线:0371-60135900 注册有礼 登录
  • 挂牌上市企业
  • 60秒人工响应
  • 99.99%连通率
  • 7*24h人工
  • 故障100倍补偿
您的位置: 网站首页 > 帮助中心>文章内容

Oracle ADF基于AM的两种回滚写法及切换行事件(附代码)

发布时间:  2012/8/31 17:31:50

在进行行编辑时,难免会遇到切换行的时候。
此时就要友好进行提示是否保存当前行数据再切换等等。

则需要有切换行事件,PopUp弹出  确定时提交  取消时回滚。

af:table组件有selectionListener属性, 默认情况下

都是 selectionListener="#{bindings.[VO名].collectionModel.makeCurrent}"
-
 

现在如果需要获取换行的动作 则要在自己的managebean方法写此方法

如: selectionListener="#{pageFlowScope.[VO名].tableSelectionListener}" 其中pageFlowScope是我的managebean的生命周期,tableSelectionListener是我定义的 获取selectionListener的监听方法

1.public void tableSelectionListener(SelectionEvent selectionEvent,ViewObjectImpl vo) throws Exception { 
2. 
3.  Row currentRow = vo.getCurrentRow(); 
4.  String Id = (String)(currentRow.getAttribute("Id"));  5.  if("-1".equals(Id))  6.  { 
7.      RichPopup continuePop = (RichPopup)JSFUtils.findComponentInRoot("confirm2");  8.      RichPopup.PopupHints ph = new RichPopup.PopupHints();   9.      continuePop.show(ph); 
10.      return;  11.  } 
12.  GenericTableSelectionHandler.makeCurrent(selectionEvent); 
13.} 
此处校验如果该行是新增行状态的话,则会弹出Popup

GenericTableSelectionHandler.makeCurrent(selectionEvent);写的位置也很重要

<>如果写在函数的最初,则获取到currentRow为切换后的行,www.linuxidc.com 在此句之前执行的currentRow都为切换行之前的currentRow.

代码中JSFUitls.findComponentInRoot("confirm2")为找到 id为confirm2的组件

UI上是这么写的:

<af:popup autoCancel="enabled" id="afterCommit" animate="default"
                                                      contentDelivery="lazyUncached">
                                                <af:dialog title="请确认" type="none" id="d2">
                                                    <af:activeOutputText value="是否保存?" id="aot2"/>
                                                    <f:facet name="buttonBar">
                                                        <af:group id="g2">
                                                            <af:commandButton text="确定" id="cb3111"
                                                                              actionListener="#{pageFlowScope.[自己的MB].makeSureButtonAction}"/>
                                                            <af:commandButton text="取消" id="cb4"
                                                                              actionListener="#{pageFlowScope.[自己的MB].makeNoButtonAction}"/>
                                                        </af:group>
                                                    </f:facet>
                                                </af:dialog>
                                            </af:popup>

 

确定走makeSureButtonAction,取消走makeNoButtonAction

确定就把am提交。取消则回滚。

介绍两种回滚方式:

1。数据库回滚,am.getDBTransaction().rollback();通过得到am的dbtransaction的回滚方法 界面上的值也会回滚成数据库的值

2. 同样是数据库的回滚 am.getDBTransaction().createPreparedStatement("commit", 1).getConnection().rollback();

与1的区别为界面上的值是不会回滚成数据库的值的,仍然保留更改过的值


本文出自:亿恩科技【www.enkj.com】

服务器租用/服务器托管中国五强!虚拟主机域名注册顶级提供商!15年品质保障!--亿恩科技[ENKJ.COM]

  • 您可能在找
  • 亿恩北京公司:
  • 经营性ICP/ISP证:京B2-20150015
  • 亿恩郑州公司:
  • 经营性ICP/ISP/IDC证:豫B1.B2-20060070
  • 亿恩南昌公司:
  • 经营性ICP/ISP证:赣B2-20080012
  • 服务器/云主机 24小时售后服务电话:0371-60135900
  • 虚拟主机/智能建站 24小时售后服务电话:0371-60135900
  • 专注服务器托管17年
    扫扫关注-微信公众号
    0371-60135900
    Copyright© 1999-2019 ENKJ All Rights Reserved 亿恩科技 版权所有  地址:郑州市高新区翠竹街1号总部企业基地亿恩大厦  法律顾问:河南亚太人律师事务所郝建锋、杜慧月律师   京公网安备41019702002023号
      1
     
     
     
     

    0371-60135900
    7*24小时客服服务热线