Saturday, November 30, 2013

Reusable Codes in OAF



Reusable Codes For OAF




  • By default setting some value for field on page load write the following code in       processRequist
           //Capturing the item in the page.
OAMessageTextInputBean name =(OAMessageTextInputBean)webBean.findChildRecursive("FullName");
// “FullName”  id of the field
               
name.setText("SANGU");            //Set the required value to that field.


  • To get the value of a field write the following code

    OAMessageTextInputBean msc = (OAMessageTextInputBean)webBean.findChildRecursive("EmployeeName");

     msc = msc.getValue(pageContext).toString();

  • To hide some field write the following code in processRequist
OAMessageTextInputBean manager
 = (OAMessageTextInputBean)webBean.findChildRecursive("ManagerId");
manager.setRendered(false);

  • To clear the fields
      if(pageContext.getParameter("Clear")!=null)
      {
        OAMessageTextInputBean  mstb 
         = (OAMessageTextInputBean)webBean.findChildRecursive("item1");

        mstb.setValue(pageContext,null);

          OAMessageTextInputBean  mstb1 =(OAMessageTextInputBean)webBean.findChildRecursive("item2");

          mstb1.setValue(pageContext,null);
         }

  •   To clear the Page

      if (pageContext.getParameter("Clear")!=null)             //Clear is the id of the clear button
      {
        pageContext.forwardImmediatelyToCurrentPage(null,false,null);
      }

  •  For message choice item to display LOV set the following in item property

                DATA--->

                 Picklist View Instance:-Give the vo name(HelloWordVO)
                 Picklist Display Attribute:Which column should display(Deptno)
                 Picklist Value Attribute:-Which column values should display(Deptno)

                BC4J--->

                 View Instance:-select the view instance name(HelloWordVO1)
                 View Attribute:-Select the column (Deptno)

  •   Passing Control from one page to another page
  if(pageContext.getParameter("item8")!=null)
      {
                pageContext.setForwardURL("OA.jsp?page=/ascon/oracle/apps/po/MyprojectPRJ/webui/Emplo                yeedetailsPG",
                                   null,
                                   OAWebBeanConstants.KEEP_MENU_CONTEXT,
                                   null,
                                   null,
                                   true,
                                   OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
                                   OAWebBeanConstants.IGNORE_MESSAGES);
      }

  •  Calling the D2K Form from OAF
           

          if(pageContext.getParameter("submit")!=null)     //give the id of the submit button.
          {
            //form:APPLICATION_SHORT_NAME:RESPONSIBILITY_KEY:DATA_GROUP_NAME
            //:FORM_FUNCTION_NAME
        
              String destination =
             "form:SYSADMIN:SYSTEM_ADMINISTRATOR:STANDARD:FND_FNDSCAUS";
                                    
              pageContext.forwardImmediatelyToForm(destination);
          }
 

  •  For single select in radio button write the following code in processRequest  of the controller
                 OAMessageRadioButtonBean var1 
                  = (OAMessageRadioButtonBean)webBean.findChildRecursive("Male");
                var1.setName("Gender");                           //Cerate’s the group for the radio buttons
                var1.setValue("Male");
               
    OAMessageRadioButtonBean var2
    = (OAMessageRadioButtonBean)webBean.findChildRecursive("Female");
                var2.setName("Gender");     
    var2.setValue("Female");
 
  • While registering our project to the server we have to import the files (xml import)
               
                C:\dev\oaf\r1211\jdevbin\oaext\bin

import C:\dev\oaf\r1211\jdevhome\jdev\myprojects\ascon\oracle\apps\po\MasterDetailPRJ\webui\MasterDetailPG.xml -rootdir C:\dev\oaf\r1211\jdevhome\jdev\myprojects -username apps - password apps -dbconnection                 "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=focusthreadr12.com)(PORT=1521))(CONNECT_DATA=(SID=visr12)))"


  •  While customization we have to import the java files.
               
jpximport C:\dev\oaf\r1211\jdevhome\jdev\myprojects\VOExtension.jpx  -username apps -  password apps –dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=focusthreadr12.com)(PORT=1521))(CONNECT_DATA=(SID=visr12)))"

  • For Bundled Exception
                ArrayList exc=new ArrayList();                   //first we have to initialize the ArrayList
                Write the following code

                write the following code inside the conditions for ex inside the save event.

                if(eventName.equalsIgnoreCase("saveEvent"))
                {              //This code will validate after we clicking on save.

                if(empname.contains("@"))
                {
                exc.add(new OAException("Special character not allowed",OAException.ERROR));
                }
                if("".equalsIgnoreCase(pageContext.getParameter("StartDate").trim()))
                {
                exc.add(new OAException("Start date shold not be null",OAException.ERROR));
                }
                if(!exc.isEmpty())
                {
                OAException.raiseBundledOAException(exc);
                }
                }


  • Creating Message in FrontEnd  For Exception.
                Switch to Functional Administrator Responsibility
                Core Services--->messages-->Create message
                Code:-
                Application Name:-
                Language:-
                Text:-                    //Employee (&EMPNO)  has been created successfully.
                Apply it.
               

                Goto jDeveloper write the following code
                String eno=pageContext.getParameter("EmployeeId")
                MessageToken [] token = new MessageToken ("EMPNO",+EmployeeId);
                throw new OAException("Application Name","Code",token);



  • TO Get The Sequence Value write the following in the create Attribute set in EO.
 public void create(AttributeList attributeList)
  {
super.create(attributeList);
   
                 OADBTransaction transaction = getOADBTransaction();
   
                 // DEFAULT: supplier id is obtained from the table's sequence
                 Number supplierId = transaction.getSequenceValue("FWK_TBX_SUPPLIERS_S");
                setSupplierId(supplierId);
  
  }  // end create()