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