Now that we are able to Insert record, search for records and update table records from a OAF screen, let us find out steps to delete a record in the table from a OAF screen. So, here it goes, below are the steps that shows deletion of records in a table from a OAF screen.
Requirement: To delete records of a table from OAF screen
Step 1: Complete creating a workspace and project as in Search Record article. Also refer to Update Record article
Step 2: Create a Delete action item
Right click on table region SearchRecordVO1 -> New -> Item
Set the properties of the item created as shown below:
Image URI –> deleteicon_enabled.gif
Atribute Set -> /oracle/apps/fnd/attributesets/Buttons/Delete
Click on browse button for parameters under Client action pane and enter the parameter name and values as in the below screenshot:
Name – deleteColumn1
Value -- ${oa.SearchRecordVO1.Column1}
Name – deleteColumn2
Value -- ${oa.SearchRecordVO1.Column2}
Step 3: Add the below code in SearchRecordCO:
PFR:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if ("delete".equals(pageContext.getParameter(EVENT_PARAM))) {
OAException message = new OAException("Are you sure you want to delete this row?",OAException.WARNING);
pageContext.putDialogMessage(message);
OADialogPage dialogPage = new OADialogPage(OAException.WARNING, message, 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);
pageContext.redirectToDialogPage(dialogPage);
}
else if (pageContext.getParameter("DeleteYesButton") != null) {
am.invokeMethod("deleteRecord", null);
OAException confirmation = new OAException("Record deleted Successfully", OAException.CONFIRMATION);
pageContext.putDialogMessage(confirmation);
}
Step 4: Add the below code in SearchRecordAMImpl
public void deleteRecord()
{
OAViewObject vo = getSearchRecordVO1();
SearchRecordVORowImpl 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 = (SearchRecordVORowImpl)deleteIter.getRowAtRangeIndex(i);
row.remove();
getTransaction().commit();
break;
}
}
deleteIter.closeRowSetIterator();
}
Result:
Search for data and click on delete icon in column 4:
Deletion confirmation page comes up - click Yes:
Deletion confirmation message:
Search for val1 to see that no result comes up indicating the successful deletion of record.
Comments
RSS feed for comments to this post