Friday, 14 November 2014

24. Using OADialogPage in OAF

We can display an exception as a message in a dialog page using the APIs in the oracle.apps.fnd.framework.webui.OADialogPage class and OAPageContext interface. The OADialogPage class holds properties for the generic dialog page.

Consider below example, where on clicking on 'Save' button after making changes on the page, it navigates to a dialog page.




This is just like asking for confirmation before saving.
Depending upon user's action (Yes or No) on dialog page, we can commit or rollback the transaction.

Below is sample code for implementing this functionality:

// 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. Hello
    i have a similar scenario with radio button.
    User is selecting a Row with Radio Button and that row is not selected. (i have 3 rows and i select one of them)
    if user is selecting the External choice, even then, the radio button is not showing that Row with EXTERNAL choice is highlighted.
    Can you please help me what mistake i do in the below code.

    BTW the corresponding VO of this table RN is not based on EO. So i want to know how to commit in this scenario

    User is selecting a Row with Radio Button and that row is not selected. (i have 3 rows and i select one of them)
    if user is selecting the External choice, even then, the radio button is not showing that Row with EXTERNAL choice is highlighted.
    Can you please help me what mistake i do in the below code.

    BTW the corresponding VO of this table RN is not based on EO. So i want to know how to commit in this scenario

    Should i add the save changes method as you mentioned inside AMimpl.java? SHould i extend the AM for that?

    Following is the code. This Region has VO (VO not based on EO).
    If I add OADBTransaction commit inside AMImpl.java will that help?
    please advise


    if(pageContext.getParameter("SaveYes")!=null)
    //&&(attrValue.equalsIgnoreCase("External")))
    {

    Row[] CurrRowArray= SourceVO.getFilteredRows("SourceType","External");
    int numRows = CurrRowArray.length;
    if(numRows==1){
    //Row i=Curr.setAttribute("SelectAttr","Y");
    Row CurrRow=CurrRowArray[0];
    String attrValue = (String)CurrRow.getAttribute("SourceType");
    pageContext.writeDiagnostics(this,"Continue: Yes Choice1",1);
    CurrRow.setAttribute("SelectAttr","Y");
    pageContext.writeDiagnostics(this,"Continue: Yes Choice2",1);
    }//numRows==1
    SourceAM.getOADBTransaction().commit();
    }//if((pageContext. getParameter("SaveYes")!=null) &&(attrValue.equalsIgnoreCase( "External")))


    ReplyDelete