Search page in OAF


Search page in OAF

For Search page First create on workspace and project.

Create one AM.

Create the page and attach the AM.

Create the VO with following query.

 SELECT * FROM fwk_tbx_employees
    WHERE EMPLOYEE_ID LIKE NVL(:1, EMPLOYEE_ID)
            AND FIRST_NAME LIKE NVL(:2, FIRST_NAME)

Attach the VO to AM

The structure of the page is as follows.

Create two message text input items for the input
            Such as EmployeeId and Name

Create three button for search, clear and create new employee.

Create on table region for displaying searched items.

Right click on main region select new-- > Region using Wizard.

First u will get the welcome window just click next .

In next window select your AM and VO.
Click next.



In next window select  region style as table.



In next step select the attributes u want to display.



Click next next and finish.


The final page structure is as follows.







Still now we have not yet write any code for serch.

Create one method in AMImpl.java file for search

        public void Searchemp (OAPageContext pc, OAWebBean wb)
        {    
          String eno = null;
          String ename = null;
         
         
          OAViewObject vo= getSearchVO1();
          if(pc.getParameter("item1")!=null)   //id of the search item
          {
            eno = pc.getParameter("item1").toString();
            vo.setWhereClauseParam(0,eno);
          }
          else
          {
           vo.setWhereClauseParam(0,null);
          }
          if(pc.getParameter("item2")!=null)
          {
           ename =pc.getParameter("item2").toString();
           vo.setWhereClauseParam(1,ename);
          }
          else
          {
           vo.setWhereClauseParam(1,null);
          }
         
          vo.executeQuery();
        }



Next create one controller in search page.


Write the following in the processFormRequest of  the controller.

      searchAMImpl am= (searchAMImpl)pageContext.getApplicationModule(webBean);
          
//For search after clicking the search button


            if(pageContext.getParameter("item3")!=null)  //id of search button
            {
              am.Searchemp(pageContext,webBean);
            }

           
//To clear the fields after cliking the clear button.


            if(pageContext.getParameter("item4")!=null)  //id of clear button
            {
              OAMessageTextInputBean mstb = (OAMessageTextInputBean)webBean.findChildRecursive("item1");
              mstb.setValue(pageContext,null);
              OAMessageTextInputBean mstb1 = (OAMessageTextInputBean)webBean.findChildRecursive("item2");
              mstb1.setValue(pageContext,null);
            
            }
           


      //To call the create employee page after clicking the create employee button.


      if(pageContext.getParameter("item5")!=null)  //id of add new employee
      {
        pageContext.setForwardURL("OA.jsp?page=/sangu/oracle/apps/po/PPRPRJ/webui/EmployeeCreationPG",
                                   null,
                                   OAWebBeanConstants.KEEP_MENU_CONTEXT,
                                   null,
                                   null,
                                   true,
                                   OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
                                   OAWebBeanConstants.IGNORE_MESSAGES);
      }


Run the page to see the output.


1 comment: