ITPub博客

首页 > 数据库 > Oracle > Delete Records in OAF Page

Delete Records in OAF Page

Oracle 作者:贾三灌汤包 时间:2014-04-04 15:51:37 0 删除 编辑

1. Create a Search Page to Create a page please go through the following link

https://blogs.oracle.com/prajkumar/entry/create_oaf_search_page

 


2. Implement a Delete in your SearchEOImpl Class

public void remove()
{ super.remove();
} // end remove()


 

3. Create a Delete Image

Select ResultsTable right click > New > Item

Set following properties for New Item

ID – DeleteAction

Item Style – image

Image URI – deleteicon_enabled.gif

Atribute Set -- /oracle/apps/fnd/attributesets/Buttons/Delete

Prompt -- Delete

Additional Text – Delete record action enabled

Height – 24

Width – 24

Action Type – fireAction

Event – delete

Submit – True

Select Parameter Properties define parameter name as Column1 and whose value is

${oa.SearchVO1.Column1}

Select Parameter Properties define parameter name as Column2 and whose value is

${oa.SearchVO1.Column2}

Select OK button to create your request parameters

 

4. Add Page Controller

Add a New Contoller for SearchPG

Name – SearchCO

Package -- prajkumar.oracle.apps.fnd.searchdemo.webui

 

Implement Delete Action

5. Add deleteRecord() method to SearchAMImpl

import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
import oracle.jbo.domain.Number;
import oracle.apps.fnd.framework.server.OAViewObjectImpl;
import oracle.jbo.RowSetIterator;
...

public void deleteRecord(String Column1)
{ OAViewObject vo = (OAViewObject)getSearchVO1();
  SearchVORowImpl row = null;

  int fetchedRowCount = vo.getFetchedRowCount();

 RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
  if (fetchedRowCount > 0)
  {  deleteIter.setRangeStart(0); 
     deleteIter.setRangeSize(fetchedRowCount);
     for (int i = 0; i < fetchedRowCount; i++)
    {
      row = (SearchVORowImpl)deleteIter.getRowAtRangeIndex(i);
      row.remove();
      getTransaction().commit();
      break;
    }
  }
 deleteIter.closeRowSetIterator();
} // end deleteRecord

 

Note – Create Standard FND Messages DELETE_RECORD_WARN and DELETE_CONFIRM

 

 


 


6. Add DeleteSelection Handler Code to SearchCO.processFormRequest()

import com.sun.java.util.collections.HashMap;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.OARow;
import oracle.apps.fnd.framework.OAApplicationModule;
...

OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAViewObject vo =(OAViewObject)am.findViewObject("SearchVO1");

String rowRef =
 pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);

OARow row = (OARow)am.findRowByRef(rowRef);

if ("delete".equals(pageContext.getParameter(EVENT_PARAM)))
{
 String Column1 = (String)row.getAttribute("Column1");
 String Column2 = (String)row.getAttribute("Column2");

 String Column3 = pageContext.getParameter("Column1");
 String Column4 = pageContext.getParameter("Column2");

 MessageToken[] tokens = { new MessageToken("COLUMN1", Column1),
         new MessageToken("COLUMN2", Column2)};

 OAException mainMessage = new OAException("FND",
  "DELETE_RECORD_WARN", 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);

 java.util.Hashtable formParams = new java.util.Hashtable(1);
 formParams.put("Column1", Column3);
 formParams.put("Column2", Column4);
 dialogPage.setFormParameters(formParams);

 pageContext.redirectToDialogPage(dialogPage);
}


 

7. Add Delete Confirmation Handler Code to SearchCO.processFormRequest()

import java.io.Serializable;
import oracle.apps.fnd.framework.OAApplicationModule;
...

else if (pageContext.getParameter("DeleteYesButton") != null)
{
 String Column1 = (String)row.getAttribute("Column1");
 String Column2 = (String)row.getAttribute("Column2");
 Serializable[] parameters = { Column1 };

 OAApplicationModule am =
   pageContext.getApplicationModule(webBean);

 am.invokeMethod("deleteRecord", parameters);

 OAException message = new OAException("FND",
   "DELETE_CONFIRM", null,
   OAException.CONFIRMATION, null);

 pageContext.putDialogMessage(message);
}


 

8. Congratulation you have successfully finished. Run Your page and Test Your Work

 

 


 


 


 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22816976/viewspace-1136166/,如需转载,请注明出处,否则将追究法律责任。

下一篇: OAF Sample Code
请登录后发表评论 登录
全部评论

注册时间:2009-11-03

  • 博文量
    128
  • 访问量
    225792