Oracle ADF基于AM的兩種回滾寫(xiě)法及切換行事件(附代碼) |
發(fā)布時(shí)間: 2012/8/31 17:31:50 |
在進(jìn)行行編輯時(shí),難免會(huì)遇到切換行的時(shí)候。 則需要有切換行事件,PopUp彈出 確定時(shí)提交 取消時(shí)回滾。 af:table組件有selectionListener屬性, 默認(rèn)情況下 都是 selectionListener="#{bindings.[VO名].collectionModel.makeCurrent}" 現(xiàn)在如果需要獲取換行的動(dòng)作 則要在自己的managebean方法寫(xiě)此方法 如: selectionListener="#{pageFlowScope.[VO名].tableSelectionListener}" 其中pageFlowScope是我的managebean的生命周期,tableSelectionListener是我定義的 獲取selectionListener的監(jiān)聽(tīng)方法 1.public void tableSelectionListener(SelectionEvent selectionEvent,ViewObjectImpl vo) throws Exception { GenericTableSelectionHandler.makeCurrent(selectionEvent);寫(xiě)的位置也很重要 <>如果寫(xiě)在函數(shù)的最初,則獲取到currentRow為切換后的行,www.linuxidc.com 在此句之前執(zhí)行的currentRow都為切換行之前的currentRow. 代碼中JSFUitls.findComponentInRoot("confirm2")為找到 id為confirm2的組件 UI上是這么寫(xiě)的: <af:popup autoCancel="enabled" id="afterCommit" animate="default"
確定走makeSureButtonAction,取消走makeNoButtonAction 確定就把a(bǔ)m提交。取消則回滾。 介紹兩種回滾方式: 1。數(shù)據(jù)庫(kù)回滾,am.getDBTransaction().rollback();通過(guò)得到am的dbtransaction的回滾方法 界面上的值也會(huì)回滾成數(shù)據(jù)庫(kù)的值 2. 同樣是數(shù)據(jù)庫(kù)的回滾 am.getDBTransaction().createPreparedStatement("commit", 1).getConnection().rollback(); 與1的區(qū)別為界面上的值是不會(huì)回滾成數(shù)據(jù)庫(kù)的值的,仍然保留更改過(guò)的值 本文出自:億恩科技【www.laynepeng.cn】 服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM] |