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();
        if (fetchedRowCount > 0)
            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.
       break; // only one possible selected row in this case       

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.