Two Methods of Oracle adf am-based rollback writing and switching row events (with code)

Source: Internet
Author: User

When you edit a row, you will inevitably encounter switching rows.
 
In this case, you need to kindly prompt whether to save the data of the current row and then switch.
 
A switching row event is required. When PopUp pops up, the rollback is triggered when the job is canceled.
 
Af: The table component has the selectionListener attribute. By default
 
All are selectionListener = "# {bindings. [VO name]. collectionModel. makeCurrent }"
 
If you need to get the line feed action, you need to write this method in your own managebean method.
 
For example, selectionListener = "# {pageFlowScope. [VO name]. tableSelectionListener}" where pageFlowScope is the life cycle of my managebean, tableSelectionListener is the method I defined to obtain the selectionListener listener.
 
Public void tableSelectionListener (SelectionEvent selectionEvent, ViewObjectImpl vo) throws Exception {
 
Row currentRow = vo. getCurrentRow ();
String Id = (String) (currentRow. getAttribute ("Id "));
If ("-1". equals (Id ))
{
RichPopup continuePop = (RichPopup) JSFUtils. findComponentInRoot ("confirm2 ");
RichPopup. PopupHints ph = new RichPopup. PopupHints ();
ContinuePop. show (ph );
Return;
}
GenericTableSelectionHandler. makeCurrent (selectionEvent );
}
Public void tableSelectionListener (SelectionEvent selectionEvent, ViewObjectImpl vo) throws Exception {
 
Row currentRow = vo. getCurrentRow ();
String Id = (String) (currentRow. getAttribute ("Id "));
If ("-1". equals (Id ))
{
RichPopup continuePop = (RichPopup) JSFUtils. findComponentInRoot ("confirm2 ");
RichPopup. PopupHints ph = new RichPopup. PopupHints ();
ContinuePop. show (ph );
Return;
}
GenericTableSelectionHandler. makeCurrent (selectionEvent );
} Here, if this row is in the new row status, Popup will pop up.
 
 
GenericTableSelectionHandler. makeCurrent (selectionEvent); The write position is also important.
 
<> If it is written at the beginning of the function, the row with currentRow being switched is obtained, and the currentRow executed before this sentence is the currentRow before the row is switched.
 
In the code, JSFUitls. findComponentInRoot ("confirm2") is the component whose id is confirm2.
 
This is written on the UI:
 
<Af: popup autoCancel = "enabled" id = "afterCommit" animate = "default"
ContentDelivery = "lazyUncached">
<Af: dialog title = "Please confirm" type = "none" id = "d2">
<Af: activeOutputText value = "Save? "Id =" aot2 "/>
<F: facet name = "buttonBar">
<Af: group id = "g2">
<Af: commandButton text = "OK" id = "cb3111"
ActionListener = "# {pageFlowScope. [your own VO]. makeSureButtonAction}"/>
<Af: commandButton text = "cancel" id = "cb4"
ActionListener = "# {pageFlowScope. [your own VO]. makeNoButtonAction}"/>
</Af: group>
</F: facet>
</Af: dialog>
</Af: popup>
 
 
 
Are you sure you want to take the makeSureButtonAction and cancel the makeNoButtonAction?
 
If you are sure, submit am. If it is canceled, the system will roll back.
 
Two rollback methods are introduced:
 
1. Database rollback, am. getDBTransaction (). rollback (); the values on the interface for obtaining the rollback method of am dbtransaction will also be rolled back to the Database Value.
 
2. Similarly, the database rollback am. getDBTransaction (). createPreparedStatement ("commit", 1). getConnection (). rollback ();
 
The difference from 1 is that the interface value will not be rolled back to the database value, and the changed value will still be retained.
 
From the column haqer0825

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.