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

在进行行编辑时,难免会遇到切换行的时候。

此时就要友好进行提示是否保存当前行数据再切换等等。

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

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

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

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

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

publicvoidtableSelectionListener(SelectionEvent selectionEvent,ViewObjectImpl vo)throwsException {

Row currentRow = vo.getCurrentRow();

String Id = (String)(currentRow.getAttribute("Id"));

if("-1".equals(Id))

{

RichPopup continuePop = (RichPopup)JSFUtils.findComponentInRoot("confirm2");

RichPopup.PopupHints ph =newRichPopup.PopupHints();

continuePop.show(ph);

return;

}

GenericTableSelectionHandler.makeCurrent(selectionEvent);

}

此处校验如果该行是新增行状态的话,则会弹出Popup

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

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

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

UI上是这么写的:

contentDelivery="lazyUncached">

actionListener="#{pageFlowScope.[自己的MB].makeSureButtonAction}"/>

actionListener="#{pageFlowScope.[自己的MB].makeNoButtonAction}"/>

确定走makeSureButtonAction,取消走makeNoButtonAction

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

介绍两种回滚方式:

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

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值