Sunday, 24 November 2013

                           How  To  Debugg Errors in OAF



Debugging Errors in Local Machine




1. Using sop Statments In Controller:

        system.out.println(" Enters into The statement");

2.Using Internal Debugger in the Statement:


Put Break points Which You Want to run




After run The page It shows Arrow mark on the Code . so Press F9. it follow the flow and if any Error is there it skips the flow. we Can see this is logg window.


Debugg  Errors  in Server:

Here we can Debug using Following statement  in Controller:

 pageContext.writeDiagnostics(this, "I am at disble item3", 
                                     OAFwkConstants.STATEMENT);


IN AM:

OADBTransaction.writeDiagnostics(this, "I am at disble item3", 
                                     OAFwkConstants.STATEMENT);


Using Diagnostics:




  











Passing parameters from one OAF page to another OAF Page




Ways to pass parameters in Request:

·                     Adding in URL: We can specify parameters as literal values or token substituted values (mapped to VO Attributes). Following are the examples:
o                  OA.jsp?page=/xxabc/oracle/apps/xxabc/custommodule/webui/CustomPG&order={@OrderNum}
o                  OA.jsp?OAFunc=XXABC_ADM_SUPP_ENGR&asset=123
·                     OAPageContext.putParameter()
o                  Values are not technically added to request, but are stored in a special page cache.
o                  Equivalent to HttpServletRequest.setAttribute()
·                     Hidden fields (form values)
·                     Passing parameters in Hashmap using setForwardUrl().
1.HashMap xxhashMap = new HashMap(1);
xxhashMap .put("ParamName1", "Value1");

oapagecontext.setForwardURL("MY_FUNCTION", (byte)0, null, xxhashMap , true, "N", (byte)0);

OR
oapagecontext.setForwardURL("OA.jsp?page=/xxelng/oracle/apps/per/hiring/webui/XXConfermationPG", 
                                      null,
 
                                      OAWebBeanConstants.KEEP_MENU_CONTEXT,
 
                                      null, xxhashMap , true,
 
                                      OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
 
                                      OAWebBeanConstants.IGNORE_MESSAGES);

You can then retrieve this parameter in processRequest() via:
oapagecontext.getParameter("ParamName1");


Passing parameters in Hashmap is the better approach for following reasons:
1.             URL has size restrictions.
2.             URL is visible to users.
3.             putParamater() and hidden fields are not stored in Request as parameters, thus if we navigate with Breadcrumbs or for other reasons in case the webBean hierarchy needs to be reconstructed, these will not be available.

Transaction:

Transaction has wider scope than Request thus its not preferred approach.
·                     OAPageContext.putTransactionValue()
·                     OAPageContext.getTransactionValue()
·                     ((OADBTransactionImpl)getTransaction()).putValue()
·                     ((OADBTransactionImpl)getTransaction()).getValue()

Session:

Again, a wider scope than Transaction and not recommended.

·                     pageContext.putSessionValue();
·                     pageContext.getSessionValue();



Multi Delete in OAF


1. Create Item Under rowlayout Region Style SubmitButton Id&Prompt: MultiDelete
2. Create Transist Attribute in XXSearchVO Name:XXMDelete, Type:String
3. Rt Click on Table Region_MultipleSelection_InProperties
     View Instance: XXSearchVO
     View Attribute: XXMDelete(TransistAttribute)
4. Write Code SearchCO in ProcessFoamRequest
    if(pageContext.getParameter("MultiDelete")!=null)
{
OAViewObject vo=(OAViewObject)am.getXXSearchVO1();
for (XXSearchVORowImpl row=(XXSearchVORowImpl)vo.first();
row!=null;row=(XXSearchVORowImpl)vo.next())
{
if(row.getAttribute("XXMDelete")!=null && row.getAttribute("XXMDelete").equals("Y"))
{
String hid=row.getAttribute("HeaderId").toString();
String query="delete from XXCUSTOMER_REBATELINE where HEADER_ID="+hid;
try
{
PreparedStatement
ps=am.getOADBTransaction().getJdbcConnection().prepareStatement(query);
ps.executeUpdate();
}
catch (Exception e)
{
e.printStackTrace();
}
row.remove();
am.getOADBTransaction().commit();
} } }
Capturing Values from Lov()
if (pageContext.isLovEvent())
    {
      pageContext.writeDiagnostics(this, "I am at disble item2",
                                   OAFwkConstants.STATEMENT);
      String lovid = pageContext.getLovInputSourceId();

      if ("Category".equals(lovid))
      {
        pageContext.writeDiagnostics(this, "I am at disble item3",
                                     OAFwkConstants.STATEMENT);
        String category = pageContext.getParameter("Category").toString();
        pageContext.writeDiagnostics(this, "I am at disble item4" + category,
                                     OAFwkConstants.STATEMENT);

        
Creating the button programmatically

  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    //first excute standard functionality by call super as below
    super.processRequest(pageContext, webBean);
    //now create new button programatically
    OASubmitButtonBean oasb= (OASubmitButtonBean)pageContext.getWebBeanFactory().createWebBean(pageContext,"BUTTON_SUBMIT");
    oasb.setID("xxSubmitSendEmailButton");
    oasb.setUINodeName("xxSubmitSendEmailButton");
    oasb.setEvent("xxSubmitSendEmailButton");
    oasb.setText("xxSubmitSendEmailButton");
    webBean.addIndexedChild(oasb);
  }

Dynamically creating of Advance Table  Bean:

 private void setReportSumText(OAPageContext pageContext, OAWebBean webBean) 
  {
    OAAdvancedTableBean advancedTableBean = (OAAdvancedTableBean)webBean.findIndexedChildRecursive("BuyerTableRN");
    advancedTableBean.prepareForRendering(pageContext);
    if (advancedTableBean != null)
    {
      OATableFooterBean tableFooterBean = (OATableFooterBean)advancedTableBean.getFooter();
      if(tableFooterBean != null)
      {
        OATotalRowBean totalRowBean = (OATotalRowBean)tableFooterBean.getTotal();
        if(totalRowBean != null)
        {
          totalRowBean.setText("Report-Sum");
        }
      }
   }
  }
Loop Throught the Fetched Records in VO
Example 1:

This particular example was written for Oracle Sourcing.
       OAApplicationModule rootAM = pageContext.getRootApplicationModule();           
       OAViewObject ReqVO   =      (OAViewObject)rootAM.findViewObject("BidHeaderSectionsVO");
           
            if (null!=ReqVO) {
                Row ReqRow = ReqVO.first();           
                if (null != ReqRow) {
                           
                int idx = ReqVO.getRowCount();
   
                for (int xx = 0; xx < idx; xx++) {
                    if (null != ReqRow) {
                       // Do some work....
                       ReqRow = ReqVO.next();
                    }
                    else {}
                }
              }
            }

Example 2:
OAViewObject vo = (OAViewObject)getPPVCMHeadersVO2();
   PPVCMHeadersVORowImpl row = null;
   int fetchedRowCount = vo.getRowCount();
   RowSetIterator insertIter = vo.createRowSetIterator("insertIter");
   if (fetchedRowCount > 0)
    {
     insertIter.setRangeStart(0);
     insertIter.setRangeSize(fetchedRowCount);
     for (int i = 0; i < fetchedRowCount; i++)
      {  
        row = (PPVCMHeadersVORowImpl)insertIter.getRowAtRangeIndex(i);
        row.setAttribute("Sno",new Integer(i+1));
      }
    }  



How to add where condition to the sql stament....?


public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    String resourceId=pageContext.getParameter("ResourceId");
    OAApplicationModule am = pageContext.getRootApplicationModule();
     String projectId = (String)pageContext.getSessionValue("paProjectId");
    String sWhereClauseValue = "";

    String dynVoQuery = "SELECT ppp.person_id, ppp.start_date_active, ppp.end_date_active  FROM pa_project_players ppp, pa_project_role_types ppr,pa_project_parties pp WHERE ppp.project_id = :1 and pp.project_id=ppp.project_id   AND ppp.project_role_type = ppr.project_role_type AND ppr.description = 'Delivery Manager' AND pp.project_role_id =ppr.PROJECT_ROLE_TYPE AND NVL (ppp.end_date_active, NVL (pp.START_DATE_ACTIVE, SYSDATE)) BETWEEN NVL (pp.START_DATE_ACTIVE, SYSDATE) AND NVL (pp.END_DATE_ACTIVE, TO_DATE ('01/01/4712', 'DD/MM/YYYY'))";
    ViewObject dynViewObject = am.findViewObject("ExistingDeliveryMgrVO");
    if(dynViewObject == null)
    {
      dynViewObject = am.createViewObjectFromQueryStmt("ExistingDeliveryMgrVO", dynVoQuery);
//      ExistingDeliveryMgrVORowImpl row=null;
      dynViewObject.setWhereClauseParams(null);
      dynViewObject.setWhereClauseParam(0,projectId);
      dynViewObject.executeQuery();
      if(dynViewObject.getRowCountInRange() >0)
      {
        oracle.jbo.Row row1 = dynViewObject.first();
        if(row1 != null)
        {
          String existingDeliveryMgr = row1.getAttribute(0).toString();
          if(existingDeliveryMgr != resourceId)
          {
            throw new OAException("Duplicate Delivery Manager");
          }
        }
      }