0 Replies Latest reply: Jul 9, 2013 11:12 AM by User474617-OC RSS

    Stale data error while deleting a record

    User474617-OC

      Hi

       

      My design of this development is as follow...

       

       

       

      1. Search Page in which users give some search criteria and results will be displayed in the results region on the same page. For each results record I have two buttons like 'Update' and 'Delete' so that users can delete the record or can update the record. For update i created a one more page where users can able to edit and save the data. I have two AM one for Search Page and one for Update Page.

       

      Please find more details below.

       

      intfEO  based on PO_REQUISITIONS_INTERFACE_ALL

       

      errorEO  based on PO_INTERFACE_ERRORS

       

      updateEO based on PO_REQUISITIONS_INTERFACE_ALL

       

      VOs

       

      intfVO based on intfEO and errorEO

       

      updateVO based on updateEO

       

      AM

       

      intfAM based on intfVO

       

      updateAM based on updateVO

       

      Pages

       

      searchPG based on intfAM

       

      updatePG based on updateAM

       

      Suppose I have one record in interface table with corresponding error record in error table.When users given the search criteria and hit enter they found a record. It means i have one record in the interface having one error record in the error table and both tables have same transaction id (primary key). So here user first try to update the record and it is working. After update he try to delete a record then I am getting below error. Please note that I am not getting this error when if i directly delete the record with out doing any update before delete. When ever users click on update icon then update PG will open and when users click on Apply button then data is getting updated in the database and page will forward to the search page.

       

       

       

      Unable to perform transaction on the record.

      Cause: The record contains stale data. The record has been modified by another user.

      Action: Cancel the transaction and re-query the record to get the new data.

       

       

       

      My UpdatePage Controller

       

      ----------------------------------------------

       

        

       

      /*===========================================================================+

       

      |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |

       

      |                         All rights reserved.                              |

       

      +===========================================================================+

       

      |  HISTORY                                                                  |

       

      +===========================================================================*/

       

      package powl.oracle.apps.xxpowl.po.requisition.webui;

       

       

       

      import com.sun.java.util.collections.HashMap;

       

       

       

      import com.sun.rowset.internal.Row;

       

       

       

      import java.io.Serializable;

       

       

       

      import oracle.apps.fnd.common.MessageToken;

       

      import oracle.apps.fnd.common.VersionInfo;

       

      import oracle.apps.fnd.framework.OAApplicationModule;

       

      import oracle.apps.fnd.framework.OAException;

       

      import oracle.apps.fnd.framework.OAViewObject;

       

      import oracle.apps.fnd.framework.webui.OAControllerImpl;

       

      import oracle.apps.fnd.framework.webui.OADialogPage;

       

      import oracle.apps.fnd.framework.webui.OAPageContext;

       

      import oracle.apps.fnd.framework.webui.OAWebBeanConstants;

       

      import oracle.apps.fnd.framework.webui.beans.OAWebBean;

       

       

       

      import oracle.apps.fnd.framework.webui.beans.form.OASubmitButtonBean;

       

      import oracle.apps.fnd.framework.webui.beans.message.OAMessageDateFieldBean;

       

      import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;

       

       

       

      //import oracle.apps.fnd.oam.diagnostics.report.Row;

       

      import oracle.apps.icx.por.common.webui.ClientUtil;

       

       

       

      import powl.oracle.apps.xxpowl.po.requisition.server.xxpowlPOReqIntfUpdateAMImpl;

       

      import powl.oracle.apps.xxpowl.po.requisition.server.xxpowlPOReqIntfUpdateEOVOImpl;

       

       

       

      /**

       

      * Controller for ...

       

      */

       

      public class xxpowlPOReqIntfAllUpdatePageCO extends OAControllerImpl

       

      {

       

        public static final String RCS_ID="$Header$";

       

        public static final boolean RCS_ID_RECORDED =

       

              VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

       

       

       

        /**

       

         * Layout and page setup logic for a region.

       

         * @param pageContext the current OA page context

       

         * @param webBean the web bean corresponding to the region

       

         */

       

        public void processRequest(OAPageContext pageContext, OAWebBean webBean)

       

        {

       

          super.processRequest(pageContext, webBean);

       

         

       

           xxpowlPOReqIntfUpdateAMImpl am = (xxpowlPOReqIntfUpdateAMImpl)pageContext.getApplicationModule(webBean);

       

           

       

            xxpowlPOReqIntfUpdateEOVOImpl UpdateVO =(xxpowlPOReqIntfUpdateEOVOImpl)am.findViewObject("xxpowlPOReqIntfUpdateEOVOImpl");

       

           

       

            String newvalue = (String)pageContext.getSessionValue("testValue");     

       

            System.out.println("Transaction ID from processRequest UpdateCO from testValue field:"+newvalue);

       

           

       

            String transactionid = pageContext.getParameter("HashmapTransacitonid");

       

            System.out.println("Transaction ID from processRequest Hash Map in UpdateCO :"+transactionid);

       

       

       

            String errorcolumn = pageContext.getParameter("HashmapErrorcolumn");

       

            System.out.println("Error Column Name from processRequest Hash Map in UpdateCO :"+errorcolumn);

       

       

       

            String errormsg = pageContext.getParameter("HashmapErrormessage");

       

            System.out.println("Error Message from processRequest Hash Map in UpdateCO :"+errormsg);

       

           

       

            String readyonly = pageContext.getParameter("HashmapReadonly");

       

            System.out.println("Read Only value from processRequest Hash Map in UpdateCO :"+readyonly);

       

                              

       

            if (transactionid !=null & !"".equals(transactionid)) { 

       

           /* Passing below four parameters to the Update Page */

       

            Serializable amParams[] = new Serializable[]{transactionid,readyonly,errorcolumn,errormsg} ;

       

            pageContext.getRootApplicationModule().invokeMethod("executexxpowlPOReqIntfUpdateEOVO", amParams);

       

           

       

       

       

            } 

       

       

       

        }

       

       

       

        /**

       

         * Procedure to handle form submissions for form elements in

       

         * a region.

       

         * @param pageContext the current OA page context

       

         * @param webBean the web bean corresponding to the region

       

         */

       

        public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

       

        {

       

          super.processFormRequest(pageContext, webBean);      

       

       

       

           OAApplicationModule am = pageContext.getApplicationModule(webBean);

       

       

       

            if (pageContext.getParameter("ApplyButton") != null)

       

            {

       

                             

       

              System.out.println("Inside ApplyButton method in UpdatePageCO");

       

              OAViewObject vo = (OAViewObject)am.findViewObject("xxpowlPOReqIntfUpdateEOVO");

       

               

       

              String transactionid = pageContext.getParameter("HashmapTransacitonid");

       

              System.out.println("Transaction ID from processFormRequest Hash Map in UpdateCO-ApplyButton method :"+transactionid);

       

       

       

              am.invokeMethod("apply");

       

                  

       

                pageContext.forwardImmediately("OA.jsp?page=/powl/oracle/apps/xxpowl/po/requisition/webui/xxpowlPOReqIntfAllPG",

       

                                                       null,

       

                                                       OAWebBeanConstants.KEEP_MENU_CONTEXT,

       

                                                       null,

       

                                                       null,

       

                                                       true,

       

                                                       OAWebBeanConstants.ADD_BREAD_CRUMB_NO);

       

       

       

            }  

       

       

       

           

       

             else if (pageContext.getParameter("CancelButton") != null)

       

             {

       

              am.invokeMethod("rollback");

       

              pageContext.forwardImmediately("OA.jsp?page=/powl/oracle/apps/xxpowl/po/requisition/webui/xxpowlPOReqIntfAllPG",

       

                                                     null,

       

                                                     OAWebBeanConstants.KEEP_MENU_CONTEXT,

       

                                                     null,

       

                                                     null,

       

                                                     true,

       

                                                     OAWebBeanConstants.ADD_BREAD_CRUMB_NO);

       

             } 

       

           

       

        }

       

       

       

      }

       

       

       

       

       

       

       

       

       

      UpdatePageAMImpl.java

       

      ---------------------------------

       

       

       

      package powl.oracle.apps.xxpowl.po.requisition.server;

       

       

       

      import oracle.apps.fnd.common.MessageToken;

       

      import oracle.apps.fnd.framework.OAException;

       

      import oracle.apps.fnd.framework.OARow;

       

      import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;

       

      import oracle.apps.fnd.framework.OAViewObject;

       

      import oracle.apps.inv.appsphor.order.server.XxapOrderHeaderVOImpl;

       

       

       

      import oracle.jbo.Transaction;

       

       

       

      // ---------------------------------------------------------------------

       

      // ---    File generated by Oracle ADF Business Components Design Time.

       

      // ---    Custom code may be added to this class.

       

      // ---    Warning: Do not modify method signatures of generated methods.

       

      // ---------------------------------------------------------------------

       

      public class xxpowlPOReqIntfUpdateAMImpl extends OAApplicationModuleImpl {

       

          /**This is the default constructor (do not remove)

       

           */

       

          public xxpowlPOReqIntfUpdateAMImpl() {

       

          }

       

       

       

          /**Container's getter for xxpowlPOReqIntfUpdateEOVO

       

           */

       

          public xxpowlPOReqIntfUpdateEOVOImpl getxxpowlPOReqIntfUpdateEOVO() {

       

              return (xxpowlPOReqIntfUpdateEOVOImpl)findViewObject("xxpowlPOReqIntfUpdateEOVO");

       

          }

       

       

       

          /**Sample main for debugging Business Components code using the tester.

       

           */

       

          public static void main(String[] args) {

       

              launchTester("powl.oracle.apps.xxpowl.po.requisition.server", /* package name */

       

            "xxpowlPOReqIntfUpdateAMLocal" /* Configuration Name */);

       

          }

       

       

       

      /*  // Added by 

       

          public void execute_update_query(String TransactionID) {

       

          xxpowlPOReqIntfUpdateEOVOImpl vo = getxxpowlPOReqIntfUpdateEOVO();

       

          vo.initQuery(TransactionID);

       

          }

       

      */    

       

       

       

       

       

      // Added by  , this will not call bec changed the logic and so now the update button enabled on search results page

       

      // and this method will not called

       

      public void pageInEditMode (String transactionID, String readOnlyFlag, String ErrorColumn,

       

                                                                             String ErrorMessage)

       

      {

       

          System.out.println("Transaction Id from pageInEditMode in UpdatePGAMImpl.java: "+transactionID);

       

          System.out.println("xxReadOnly from pageInEditMode in UpdatePGAMImpl.java: "+readOnlyFlag);

       

         

       

          // Get the VO

       

          xxpowlPOReqIntfUpdateEOVOImpl updateVO = getxxpowlPOReqIntfUpdateEOVO();

       

         

       

          //Remove the where clause that was added in the previous run

       

          updateVO.setWhereClause(null);

       

        

       

          //Remove the bind parameters that were added in the previous run.

       

          updateVO.setWhereClauseParams(null);

       

         

       

          //Add where clause

       

          // updateVO.addWhereClause(" TRANSACTION_ID = :1 ");

       

         

       

          //Bind transactionid to the where clause.

       

           // updateVO.setWhereClauseParam(1, transactionID); // this will not work bec it will start with zero from from 1

       

            updateVO.setWhereClauseParam(0, transactionID);

       

         

       

          //Execute the query.

       

          updateVO.executeQuery();

       

         

       

          xxpowlPOReqIntfUpdateEOVORowImpl currentRow = (xxpowlPOReqIntfUpdateEOVORowImpl)updateVO.next();

       

         

       

          // Assiging the transient varaibles

       

          currentRow.setxxErrorMessage(ErrorMessage);

       

          currentRow.setxxErrorColumn(ErrorColumn);

       

         

       

          if ("N".equals(readOnlyFlag))

       

            {

       

                /* Make the attribute to 'False so that all fields will be displayed in Edit Mode because we used this

       

                 xxReadOnly as SPEL  */

       

                 currentRow.setxxReadOnly(Boolean.FALSE);

       

            } 

       

      }

       

       

       

       

       

       

       

         public void executexxpowlPOReqIntfUpdateEOVO(String transactionID, String xxReadyOnly, String ErrorColumn,

       

                                                                                                String ErrorMessage)

       

         {

       

       

       

       

       

             System.out.println("Transaction Id from executexxpowlPOReqIntfUpdateEOVO in UpdatePGAMImpl.java: "+transactionID);

       

             System.out.println("xxReadOnly from executexxpowlPOReqIntfUpdateEOVO in UpdatePGAMImpl.java: "+xxReadyOnly);

       

             System.out.println("Error Message from executexxpowlPOReqIntfUpdateEOVO in UpdatePGAMImpl.java: "+ErrorColumn);

       

             System.out.println("Error Column from executexxpowlPOReqIntfUpdateEOVO in UpdatePGAMImpl.java: "+ErrorMessage);

       

            

       

           // Get the VO

       

           xxpowlPOReqIntfUpdateEOVOImpl updateVO = getxxpowlPOReqIntfUpdateEOVO();

       

          

       

           //xxpowlPOReqIntfUpdateEOVORowImpl updaterowVO = xxpowlPOReqIntfUpdateEOVO();

       

                 

       

         //not working

       

         //    OARow row = (OARow)updateVO.getCurrentRow();

       

         //    row.setAttribute("xxReadOnly", Boolean.TRUE);

       

            

       

            

       

            

       

      // updateVO.putTransientValue('XXXXX',x);

       

          

       

           //Remove the where clause that was added in the previous run

       

           updateVO.setWhereClause(null);

       

          

       

           //Remove the bind parameters that were added in the previous run.

       

           updateVO.setWhereClauseParams(null);

       

          

       

           //Add where clause

       

           // updateVO.addWhereClause(" TRANSACTION_ID = :1 ");

       

          

       

           //Bind transactionid to the where clause.

       

            // updateVO.setWhereClauseParam(1, transactionID); // this will not work bec it will start with zero from from 1

       

             updateVO.setWhereClauseParam(0, transactionID);

       

          // updateVO.setWhereClauseParam(1, ErorrColumn); 

       

         

       

       

       

          

       

           //Execute the query.

       

           updateVO.executeQuery();

       

          

       

           /* We want the page should be read only initially so after executing the VO with above command

       

              and if you use next() it will go to the first record among the

       

              fetched records. If you want to iterate for all the records then use iterator */

       

             

       

              /* Using Iterator

       

               while(updateVO.hasNext()) {  // this will check after execute Query above command if it has any rows

       

                xxpowlPOReqIntfUpdateEOVORowImpl currentRow = (xxpowlPOReqIntfUpdateEOVORowImpl)updateVO.next();

       

                /* above line next() will take the control of the first record */

       

            /*     currentRow.setxxErrorMessage(ErrorMessage);

       

                   currentRow.setxxErrorColumn(ErrorColumn);

       

       

       

                 if ("Y".equals(xxReadyOnly))

       

                   {

       

                        currentRow.setxxReadOnly(Boolean.TRUE);                 

       

                   }             

       

               } // this while loop will loop till end of all the fetched records

       

            */  

       

          

       

           xxpowlPOReqIntfUpdateEOVORowImpl currentRow = (xxpowlPOReqIntfUpdateEOVORowImpl)updateVO.next();

       

       

       

        // Assiging the transient varaibles

       

        currentRow.setxxErrorMessage(ErrorMessage);

       

        currentRow.setxxErrorColumn(ErrorColumn);

       

            

       

          

       

          /* Make the attribute to 'TRUE' so that all fields will be displayed as READ ONLY because we used this

       

             xxReadOnly as SPEL

       

             if ("Y".equals(xxReadyOnly))

       

               {

       

                    currentRow.setxxReadOnly(Boolean.TRUE);            

       

               }   

       

            */

       

         }

       

          

       

          

       

        //Added by  and this methiod will get called from UpdatePG Process Form Request controller  

       

           public void rollback()

       

           {

       

             Transaction txn = getTransaction();

       

       

       

             if (txn.isDirty())

       

             {

       

               txn.rollback();

       

             }

       

           }    

       

       

       

          public void apply()

       

          {

       

              //OAViewObject vo1 = (OAViewObject)getxxpowlPOReqIntfUpdateEOVO();

       

              //Number chargeAccountID = vo1.get

       

           

       

            getTransaction().commit();      

       

            OAViewObject vo = (OAViewObject)getxxpowlPOReqIntfUpdateEOVO();

       

       

       

            if (!vo.isPreparedForExecution())

       

           {

       

             vo.executeQuery();

       

            }

       

       

       

               }

       

      SearchPG AM

       

      --------------------------

       

      package powl.oracle.apps.xxpowl.po.requisition.server;

       

      import oracle.apps.fnd.framework.OAViewObject;

       

      import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;

       

      import oracle.jbo.RowSetIterator;

       

      import oracle.jbo.Transaction;

       

      import oracle.jbo.domain.Number;

       

      import powl.oracle.apps.xxpowl.po.requisition.lov.server.xxpowlErrosLovVOImpl;

       

      import powl.oracle.apps.xxpowl.po.requisition.lov.server.xxpowlInterfaceSouceCodeLovVOImpl;

       

      import powl.oracle.apps.xxpowl.po.requisition.lov.server.xxpowlItemSegment1LovVOImpl;

       

      import powl.oracle.apps.xxpowl.po.requisition.lov.server.xxpowlOrgLovVOImpl;

       

      import powl.oracle.apps.xxpowl.po.requisition.lov.server.xxpowlReferenceNumberLovVOImpl;

       

      import powl.oracle.apps.xxpowl.po.requisition.lov.server.xxpowlRequestIdLovVOImpl;

       

      import powl.oracle.apps.xxpowl.po.requisition.lov.server.xxpowlRequisitionTypeLovVOImpl;

       

      // ---------------------------------------------------------------------

       

      // ---    File generated by Oracle ADF Business Components Design Time.

       

      // ---    Custom code may be added to this class.

       

      // ---    Warning: Do not modify method signatures of generated methods.

       

      // ---------------------------------------------------------------------

       

      public class xxpowlPOReqIntfAllAMImpl extends OAApplicationModuleImpl {

       

          /**This is the default constructor (do not remove)

       

           */

       

          public xxpowlPOReqIntfAllAMImpl() {

       

          }

       

          /**Container's getter for xxpowlPOReqIntfAllVO

       

           */

       

          public xxpowlPOReqIntfAllVOImpl getxxpowlPOReqIntfAllVO() {

       

              return (xxpowlPOReqIntfAllVOImpl)findViewObject("xxpowlPOReqIntfAllVO");

       

          }

       

          /**Sample main for debugging Business Components code using the tester.

       

           */

       

          public static void main(String[] args) {

       

              launchTester("powl.oracle.apps.xxpowl.po.requisition.server", /* package name */

       

            "xxpowlPOReqIntfAllAMLocal" /* Configuration Name */);

       

          }

       

          /**Container's getter for xxpowlRequestIdLovVO

       

           */

       

          public xxpowlRequestIdLovVOImpl getxxpowlRequestIdLovVO() {

       

              return (xxpowlRequestIdLovVOImpl)findViewObject("xxpowlRequestIdLovVO");

       

          }

       

          /**Container's getter for xxpowlErrosLovVO

       

           */

       

          public xxpowlErrosLovVOImpl getxxpowlErrosLovVO() {

       

              return (xxpowlErrosLovVOImpl)findViewObject("xxpowlErrosLovVO");

       

          }

       

          /**Container's getter for xxpowlOrgLovVO

       

           */

       

          public xxpowlOrgLovVOImpl getxxpowlOrgLovVO() {

       

              return (xxpowlOrgLovVOImpl)findViewObject("xxpowlOrgLovVO");

       

          }

       

         

       

        //Start Adding by Lokesh

       

        //This method wil get invoked from the search results page Process Request

       

         public void rollbackItem()

       

         {

       

           Transaction txn = getTransaction();

       

           if (txn.isDirty())

       

           {

       

             txn.rollback();

       

           }

       

         }

       

       

       

       

       

        //This method will invoked from Controller page when user click Yes on delete confirmtion page from Search Results Page

       

       

       

         public void deleteItem(String trasnsactionID)

       

         {

       

           Number rowToDelete = new Number(Integer.parseInt(trasnsactionID));      

       

             

       

           OAViewObject vo = (OAViewObject)getxxpowlPOReqIntfAllVO();

       

           xxpowlPOReqIntfAllVORowImpl row = null;

       

           int fetchedRowCount = vo.getFetchedRowCount();

       

          

       

         //  System.out.print(fetchedRowCount);

       

           System.out.println("No of row fetched on delete method :"+fetchedRowCount);

       

          

       

           RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");

       

             System.out.println("1 :");

       

           if (fetchedRowCount > 0)

       

           {

       

               System.out.println("2 :");

       

             deleteIter.setRangeStart(0);

       

               System.out.println("3 :");

       

             deleteIter.setRangeSize(fetchedRowCount);

       

               System.out.println("4 :");

       

             for (int i = 0; i < fetchedRowCount; i++)

       

             {

       

                 System.out.println("5 :");

       

               row = (xxpowlPOReqIntfAllVORowImpl)deleteIter.getRowAtRangeIndex(i);

       

                 System.out.println("6 :");

       

               Number PK = row.getTransactionId();

       

                 System.out.println("7 :");

       

               if (PK.compareTo(rowToDelete) == 0)

       

               {

       

                   System.out.println("8 :");

       

                 row.remove();

       

                   System.out.println("9 :");

       

                 getTransaction().commit();

       

                   System.out.println("10 :");

       

                 break;

       

                   //System.out.println("11 :");

       

               }

       

             }

       

           }

       

             System.out.println("11 :");

       

           deleteIter.closeRowSetIterator();

       

             System.out.println("12 :");

       

         }

       

          /**Container's getter for xxpowlInterfaceSouceCodeLovVO

       

           */

       

          public xxpowlInterfaceSouceCodeLovVOImpl getxxpowlInterfaceSouceCodeLovVO() {

       

              return (xxpowlInterfaceSouceCodeLovVOImpl)findViewObject("xxpowlInterfaceSouceCodeLovVO");

       

          }

       

          /**Container's getter for xxpowlRequisitionTypeLovVO

       

           */

       

          public xxpowlRequisitionTypeLovVOImpl getxxpowlRequisitionTypeLovVO() {

       

              return (xxpowlRequisitionTypeLovVOImpl)findViewObject("xxpowlRequisitionTypeLovVO");

       

          }

       

          /**Container's getter for xxpowlReferenceNumberLovVO

       

           */

       

          public xxpowlReferenceNumberLovVOImpl getxxpowlReferenceNumberLovVO() {

       

              return (xxpowlReferenceNumberLovVOImpl)findViewObject("xxpowlReferenceNumberLovVO");

       

          }

       

          /**Container's getter for xxpowlItemSegment1LovVO

       

           */

       

          public xxpowlItemSegment1LovVOImpl getxxpowlItemSegment1LovVO() {

       

              return (xxpowlItemSegment1LovVOImpl)findViewObject("xxpowlItemSegment1LovVO");

       

          }

       

      }

       

      Search Page Controller

       

      -----------------------------------

       

      .

       

      /*===========================================================================+

       

      |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |

       

      |                         All rights reserved.                              |

       

      +===========================================================================+

       

      |  HISTORY                                                                  |

       

      +===========================================================================*/

       

      package powl.oracle.apps.xxpowl.po.requisition.webui;

       

      import com.sun.java.util.collections.HashMap;

       

      //import com.sun.java.util.collections.Hashtable;

       

      import java.util.Hashtable;

       

      //import java.util.HashMap;

       

      import java.io.Serializable;

       

      import javax.servlet.jsp.PageContext;

       

      import oracle.apps.fnd.common.MessageToken;

       

      import oracle.apps.fnd.common.VersionInfo;

       

      import oracle.apps.fnd.framework.OAApplicationModule;

       

      import oracle.apps.fnd.framework.OAException;

       

      import oracle.apps.fnd.framework.webui.OAControllerImpl;

       

      import oracle.apps.fnd.framework.webui.OADialogPage;

       

      import oracle.apps.fnd.framework.webui.OAPageContext;

       

      import oracle.apps.fnd.framework.webui.OAWebBeanConstants;

       

      import oracle.apps.fnd.framework.webui.TransactionUnitHelper;

       

      import oracle.apps.fnd.framework.webui.beans.OAWebBean;

       

      /**

       

      * Controller for ...

       

      */

       

      public class xxpowlPOReqIntfAllSearchPageCO extends OAControllerImpl

       

      {

       

        public static final String RCS_ID="$Header$";

       

        public static final boolean RCS_ID_RECORDED =

       

              VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

       

        /**

       

         * Layout and page setup logic for a region.

       

         * @param pageContext the current OA page context

       

         * @param webBean the web bean corresponding to the region

       

         */

       

        public void processRequest(OAPageContext pageContext, OAWebBean webBean)

       

        {

       

          super.processRequest(pageContext, webBean);

       

         

       

          //Added by Lokesh

       

            OAApplicationModule am = pageContext.getApplicationModule(webBean);

       

         

       

           if (TransactionUnitHelper.isTransactionUnitInProgress(pageContext, "updateRecord", false)) {

       

                 am.invokeMethod("rollbackItem");

       

                 TransactionUnitHelper.endTransactionUnit(pageContext, "updateRecord");

       

               }

       

         

       

         

       

         

       

        }

       

        /**

       

         * Procedure to handle form submissions for form elements in

       

         * a region.

       

         * @param pageContext the current OA page context

       

         * @param webBean the web bean corresponding to the region

       

         */

       

        public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

       

        {

       

          super.processFormRequest(pageContext, webBean);

       

               String userClicked = pageContext.getParameter("event");

       

               System.out.println("Event from processFormRequest in SearchPageCO :"+userClicked);

       

             

       

            

       

             System.out.println("Parametere Names are :- \t" + pageContext.getParameter("UpdateImage"));

       

             System.out.println("Parametere Names are :- \t" + pageContext.getParameter("event"));

       

           if (pageContext.getParameter("event") != null &&

       

               pageContext.getParameter("event").equalsIgnoreCase("Update")) { 

       

       

       

               String ReqTransactionId=(String)pageContext.getParameter("transacitonidParam");

       

               String errorcolumn=(String)pageContext.getParameter("errorcolumnParam");

       

               String errormsg=(String)pageContext.getParameter("errormessageParam");

       

               String readyonly="Y"; //(String)pageContext.getParameter("readonlyParam");

       

              

       

              

       

               System.out.println("Requisition Transaction Id  : "+ReqTransactionId);

       

               System.out.println("Error Column  : "+errorcolumn);

       

               System.out.println("Error Message  : "+errormsg);

       

               System.out.println("Read Only  : "+readyonly);

       

       

       

               HashMap params = new HashMap(4);

       

               params.put("HashmapTransacitonid",ReqTransactionId);

       

               params.put("HashmapErrorcolumn",errorcolumn);

       

               params.put("HashmapErrormessage",errormsg);

       

               params.put("HashmapReadonly",readyonly);

       

              

       

               pageContext.putSessionValue("testValue",ReqTransactionId);

       

               //System.out.println("Transaction Id passing through HashMap :- \t" + ReqTransactionId);

       

       

       

               pageContext.setForwardURL("OA.jsp?page=/powl/oracle/apps/xxpowl/po/requisition/webui/xxpowlPOReqIntfAllUpdatePG",

       

                                          null,

       

                                          OAWebBeanConstants.KEEP_MENU_CONTEXT,

       

                                          null,

       

                                          params,

       

                                          true,

       

                                          OAWebBeanConstants.ADD_BREAD_CRUMB_YES,

       

                                          OAWebBeanConstants.IGNORE_MESSAGES) ;   

       

                                       }

       

      else if (pageContext.getParameter("event") != null &&

       

               pageContext.getParameter("event").equalsIgnoreCase("Delete")) {   

       

          System.out.println("Inside Delete method in SearchCO");

       

          String deleteTransactionID=(String)pageContext.getParameter("deleteTransactionIDParam");

       

          System.out.println("Transaction Id in Delete Method :- \t" + deleteTransactionID);

       

        //  deleteTransactionID ="";  //Makeing Null because dont want to show the transaction id bec users dont know about it

       

          //MessageToken[] tokens = { new MessageToken("MESSAGE_NAME", deleteTransactionID) };

       

          MessageToken[] tokens = { new MessageToken("MESSAGE_NAME", "") };

       

          OAException mainMessage = new OAException("FND", "FND_MESSAGE_DELETE_WARNING", tokens);

       

          OADialogPage dialogPage = new OADialogPage(OAException.WARNING,mainMessage, null, "", "");

       

          String yes = pageContext.getMessage("AK", "FWK_TBX_T_YES", null);

       

          String no = pageContext.getMessage("AK", "FWK_TBX_T_NO", null);

       

          dialogPage.setOkButtonItemName("DeleteYesButton");

       

          dialogPage.setOkButtonToPost(true);

       

          dialogPage.setNoButtonToPost(true);

       

          dialogPage.setPostToCallingPage(true);

       

          dialogPage.setOkButtonLabel(yes);

       

          dialogPage.setNoButtonLabel(no);

       

         

       

          Hashtable formParams = new Hashtable(1);

       

          formParams.put("transactionIdDeleted", deleteTransactionID);

       

          dialogPage.setFormParameters(formParams);

       

          pageContext.redirectToDialogPage(dialogPage);

       

      }

       

          

       

      else if (pageContext.getParameter("DeleteYesButton") != null)

       

             {

       

              

       

              System.out.println("Inside DeleteYesButton method in SearchCO");

       

            

       

              String deleteTransactionID = (String)pageContext.getParameter("transactionIdDeleted");

       

              System.out.println("Tranaction ID getting deleted: "+deleteTransactionID);        

       

              

       

              Serializable[] parameters = { deleteTransactionID };

       

              OAApplicationModule am = pageContext.getApplicationModule(webBean);

       

              am.invokeMethod("deleteItem", parameters);

       

              OAException message1 = new OAException("CN", "CN_QUOTA_PE_DELETED",null,OAException.CONFIRMATION, null);        

       

              

       

               pageContext.putDialogMessage(message1);

       

             }    

       

          

       

          

       

          

       

          

       

      else

       

      {

       

      }

       

         }

       

      }