Anil's Blog is Best Viewed on GOOGLE CHROME

Monday, May 24, 2010

Delete Exercise [ Delete row from a Table]

When the user selects the Delete icon, we want to submit the form so we can handle the event in processFormRequest(). 


Normally, when you simply set a Destination URI property for an image, its selection results in an HTTP GET and not a POST; we want to perform a POST. To do this, we will be explicitly configuring the image to perform a form submit when selected.


Right-click on the TableRegion and select New > Item from the context menu and set this item's properties as follows.


Item Style: image
Image URl: deleteicon_enabled.gif
Action Type : fireAction
Event: delete
Submit: True






Place your cursor in the Parameters property field and select the list of values "..." button.


In the Parameters window, define a parameter whose name is TableAssignmentId and whose value is ${oa.xxIncreaseWorkVO1.AssignmentId}






This SPEL ("Simplest Possible Expression Language") syntax indicates that the value for the TableAssignmentId  parameter will be obtained from the AssignmentId attribute in the xxIncreaseWorkVO1 view instance.


Controller PFR Code:-

if ("delete".equals(pageContext.getParameter(EVENT_PARAM)))
       {
          String TableAssignmentId=pageContext.getParameter("TableAssignmentId");
          Serializable [] params = {TableAssignmentId};
          am.invokeMethod("deleteSCODetails",params );
       }

AMImpl Code:

import oracle.jbo.RowSetIterator;
import java.sql.Connection;

 public void deleteSCODetails(String TableAssignmentId)
 {
   getOADBTransaction().writeDiagnostics(this, "In the delete Method TableAssignmentId==>"   +TableAssignmentId, 1);

      OAViewObject vo = getxxIncreaseWorkVO1();
      xxIncreaseWorkVORowImpl rowi = null;

      int fetchedRowCount = vo.getRowCount();
      getOADBTransaction().writeDiagnostics(this, "Row Count is =>" + fetchedRowCount, 1);
      RowSetIterator selectIter = vo.createRowSetIterator("selectIter");

      Connection conn = getOADBTransaction().getJdbcConnection();
      try
      {
        if (fetchedRowCount > 0)
        {
            selectIter.setRangeStart(0);
            selectIter.setRangeSize(fetchedRowCount);
            
            for (int i = 0; i < fetchedRowCount; i++)
            {
            getOADBTransaction().writeDiagnostics(this, "in the foor Loop" + i , 1);
            rowi = (xxIncreaseWorkVORowImpl)selectIter.getRowAtRangeIndex(i);
            String voAssignmentId = rowi.getAssignmentId()+"";
            
            getOADBTransaction().writeDiagnostics(this, "voAssignmentId && tableAssign     id is "+voAssignmentId +","+ TableAssignmentId, 1);

     if(TableAssignmentId.compareTo(voAssignmentId) == 0)
     {
      // This performs the actual delete.
       rowi.remove();
       getTransaction().commit();
       break; // only one possible selected row in this case       
  
      }
    }
   }
  }
}

Sunday, May 2, 2010

How to throw Attribute Level Validation in AMimpl







In Application Module

import oracle.apps.fnd.framework.OAAttrValException;

if (EndDate == null) // throwing Attribute Level Validation if the endDate is NULL

          {
              throw new OAAttrValException(OAAttrValException.TYP_VIEW_OBJECT,
                "xxIncreaseWorkVO1",
                 rowi.getKey(),
                 "RoleEndDate",
                 rowi.getAttribute("RoleEndDate"),
                 "PA",
                 "XX_ROLE_ED_NOT_BLANK");
          }


Note: Don't forget to create one Primary Key in VO.