Thursday, November 2, 2017

Delete a record in OAF

    public void deleterecord(String spelhidd)
    {
        rebatesearchVOImpl vo = getrebatesearchVO1();
        vo.executeQuery();
        rebatesearchVORowImpl row = null;
        int count = vo.getFetchedRowCount();
        RowSetIterator iter = vo.createRowSetIterator("iter");
     
        if(count>0)
        {
            iter.setRangeStart(0);
            iter.setRangeSize(count);
            for (int i=0;i<count;i++)
            {
                row=(rebatesearchVORowImpl)iter.getRowAtRangeIndex(i);
                String rowhid = row.getHeaderId().toString();
                if (rowhid.equals(spelhidd))
                {
                    row.remove();
                    getOADBTransaction().commit();
                    break;
                }
            }
                         
            }
        }


Code for Controller - Which Call the Dialogue Page to Confirm Delete

if("delete_event".equals(pageContext.getParameter(EVENT_PARAM)))
{
String shid=pageContext.getParameter("pspelhidd");

System.out.println("Dialogue Page shid pspelhidd "+shid);

OAException ex=new OAException("AR","XXAN_DELETE_WARNING");

OADialogPage dpage=new OADialogPage(ex.WARNING, ex,null,"","");

dpage.setOkButtonLabel("Delete Yes");
dpage.setNoButtonLabel("Delete No");

dpage.setOkButtonToPost(true);
dpage.setNoButtonToPost(true);

dpage.setPostToCallingPage(true);

dpage.setOkButtonItemName("DeleteYes");
dpage.setNoButtonItemName("DeleteNo");

Hashtable param=new Hashtable();
param.put("dhid",shid);
System.out.println("Dialogue Page shid yes "+shid);
dpage.setFormParameters(param);

pageContext.redirectToDialogPage(dpage);

}

if(pageContext.getParameter("DeleteYes")!=null)
{
String dialogpagehid=pageContext.getParameter("dhid");
OADBTransaction trans = am.getOADBTransaction();
try
{
CallableStatement cs=trans.createCallableStatement("Begin xxcust_lines_delete(?);end;",1);
cs.setString(1,dialogpagehid);
}
catch(Exception e)
{
  e.printStackTrace();
}
System.out.println("Dialogue Page delete yes "+dialogpagehid);
am.deleterecord(dialogpagehid);

throw new OAException("Selected customer deleted successfully",OAException.CONFIRMATION);
}


No comments:

Post a Comment