OAF useful codes

1-  Depending upon user's action (Yes or No) on dialog page, we can commit or rollback the transaction.

// in processFormRequest() method:
// On clicking save button, we create a dialog page and redirect there.
if (pageContext.getParameter("saveBtn") != null) {
    OAException descMesg =
        new OAException("FND", "FND_CUSTM_SAVE_CHANGES");
    OAException instrMesg =
        new OAException("FND", "FND_CUSTM_SAVE_CHANGES");
    OADialogPage dialogPage =
        new OADialogPage(OAException.WARNING, descMesg, instrMesg, "",
                         "");
    dialogPage.setOkButtonToPost(true);
    dialogPage.setNoButtonToPost(true);
    dialogPage.setPostToCallingPage(true);
    // here we are setting names of buttons of dialog page
 dialogPage.setOkButtonItemName("SaveYes");
    dialogPage.setNoButtonItemName("SaveNo");
     
 pageContext.redirectToDialogPage(dialogPage);
}
// if user clicks Yes button, we are committing
// records and show confirmation message
else if (pageContext.getParameter("SaveYes") != null) {
    am.invokeMethod("saveRecords");
    throw new OAException("Data has been saved successfully.",
                          OAException.CONFIRMATION);
}
// if user clicks No button, we undo the changes
// i.e. rollback the transaction
else if (pageContext.getParameter("SaveNo") != null) {
    am.invokeMethod("undoChanges");
}




// In AMImpl.java:
// these are method for committing and rollbacking the transactions:
public void saveRecords() {
    getOADBTransaction().commit();
}
public void undoChanges() {
    getOADBTransaction().rollback();
}

********************************************************************************



1 comment:

  1. This comment has been removed by the author.

    ReplyDelete