Tuesday, February 7, 2017

ADF Concepts

ADF Concepts


The Oracle Application Development Framework (Oracle ADF) is an end-to-end
application framework that builds on J2EE standards and open-source technologies to simplify and accelerate implementing service-oriented applications. If you develop enterprise solutions that search, display, create, modify, and validate data using web, wireless, desktop, or web services interfaces, Oracle ADF can simplify your job. Used in tandem, Oracle JDeveloper 10g and Oracle ADF give you an environment that covers the full development lifecycle from design to deployment, with drag-and-drop data binding, visual UI design, and team development features built-in.

Business Component In ADF

All of these features can be summarized by saying that using ADF Business
Components for your J2EE business service layer makes your life a lot easier. The key ADF Business Components components that cooperate to provide the business service implementation are:

Entity Object

An entity object represents a row in a database table and simplifies modifying its data by handling all DML operations for you. It can encapsulate business logic for the row to ensure your business rules are consistently enforced. You associate an entity object with others to reflect relationships in the underlying database schema to create a layer of business domain objects to reuse in multiple applications.

Application Module

An application module is the transactional component that UI clients use to work with application data. It defines an updatable data model and top-level
procedures and functions (called service methods) related to a logical unit of work related to an end-user task.

View Object

A view object represents a SQL query and simplifies working with its results. You use the full power of the familiar SQL language to join, project, filter, sort, and aggregate data into exactly the “shape” required by the end-user task at hand. This includes the ability to link a view object with others to create master/detail hierarchies of any complexity. When end users modify data in the user interface, your view objects collaborate with entity objects to consistently validate and save the changes


ADF Task Flows

ADF task flows provide a modular approach for defining control flow in an application. Instead of representing an application as a single large JSF page flow, you can break it up into a collection of reusable task flows. Each task flow contains a portion of the application's navigational graph. The nodes in the task flows are activities. An activity node represents a simple logical operation such as displaying a page, executing application logic, or calling another task flow. The transactions between the activities are called control flow cases.

Task Flow Types

The two types of ADF task flow are:

Unbounded task flow: A set of activities, control flow rules, and managed beans that interact to allow a user to complete a task. An ADF unbounded task flow consists of all activities and control flows in an application that are not included within any bounded task flow.

Bounded task flow: A specialized form of task flow that, in contrast to an unbounded task flow, has a single entry point and zero or more exit points. It contains its own set of private control flow rules, activities, and managed beans. An ADF bounded task flow allows reuse, parameters, transaction management, and reentry.


JSF fragments


JSF page fragments are page definitions that run embedded in another JSF page. Fragments are like page includes in JavaServer Pages, with the difference that in Oracle ADF Faces they are usually used in the context of ADF regions or dynamic declarative components. You can also reference page fragments directly from a JSP includes tag added to a JavaServer Faces document (JSPX). However, in this case, and only if a page fragment has ADF bound content, you need to make sure the content of the page fragments ADF binding file (PageDef) is copied to the PageDef file of the parent page. Otherwise ADF queried data will not show.

ADF regions 

ADF regions consist of an ADF Faces af:region tag, an ADF bounded task flow and page fragments. Page fragments that are used in a bounded task flow don't need to copy their ADF binding references to the parent container, which is a huge difference between JSP includes and ADF regions. ADF regions define an interactive area on a view, a JSF document or another JSF page fragment, that developers use to show a single view or a complete, multi-step, process. ADF regions can be statically or dynamically defined. In either way they require a PageDef file and a bounded task flow to reference. ADF regions help building desktop like web applications in which users stay for long on a single page while working on a business task.

Declarative components


Declarative components allow developers to build a composite component out of existing ADF Faces components. Declarative components exist in two flavors: library driven and dynamic declarative components (ddc). The tag library driven components are declaratively built from the File | New menu option. In the JSF view option you find a declarative component menu option that steps you through building your own ADF F aces component from existing ADF Faces components. You use tag library driven declarative components to build custom components with behavior, like a tool bar or a custom file-upload handler. The goal of building declarative components is to build re-usable components that simplify development and administration by avoiding duplicate page codes. Dynamic declarative components (DDC) are used within the scope of the web application they are defined in and cannot be re-used across applications. Their main usage is to build reusable layout artifacts or page area components. For example, a custom tab canvas is what you would build using DDC components.

Page templates


Page templates are layout definitions that you use as a starter when building new pages to enforce consistent page layouts throughout applications and enterprises. Best practices are to build a page template using the ADF Faces Quick start templates. You cannot nest page templates, but you can use page templates on parent and child views (page fragments). A page template is the page level equivalent to a DDC component.

ADF Library


ADF libraries are special Oracle ADF archive files that you use to reuse bounded task flows (regions), page templates and declarative components. They are standard JAR files with extra information in the archive manifest file that allows you to import the library files into the Oracle JDeveloper Resource Palette for declarative reuse. 

Monday, February 6, 2017

Implementing custom search form in ADF programmatically (Without using af:query)

Implementing custom search form in ADF programmatically (Without using af:query)


Sometimes we need to implement custom search instead of using adf query component.
To implement custom search form , i have used a quite beautiful way to handle search and reset functionality for a View Object.
In this post i am taking Employees Table (Default HR Schema) to search and reset af:table.

  • First create a Fusion Web Application and create model (EO,VO and AM) using Employees table
  • Now suppose we have to search on 4 fields (EmployeeId, FirstName, Email, Salary) , so for this i have created a new read only ViewObject from dual
  •  This VO from dual is created to be used as Search form on page
  •  Now to make search effective on Employees VO , i have created 4 bind variable for corresponding fields in Employees ViewObject


  •  Now i have created a ViewCriteria using these 4 bind variables to re-query ViewObject  data
  •  This ViewCriteria will be executed each time when value of bind variable is changed, now this is the time to set value of bind variables, so i have dragged dual vo as a form on page, and added 2 button for Search and Reset
  •  To View Search Result , Employees Table is there on page
  •  Now to get value from Form Field to bean , i have created binding for all 4 fields in bean
  •  Now i have created ActionListener for Search button- in this code i have get value from page using component bindings and passed in Employees ViewObject's bind variable in order to execute viewCriteria.

  •     public void searchButton(ActionEvent actionEvent) {
            searchAMImpl am = (searchAMImpl)resolvElDC("searchAMDataControl");
            ViewObject empVo = am.getEmployees1();
            empVo.setNamedWhereClauseParam("EmpIdBind", empIdPgBind.getValue());
            empVo.setNamedWhereClauseParam("FirstNmBind", firstNmPgBind.getValue());
            empVo.setNamedWhereClauseParam("EmailBind", emailPgBind.getValue());
            empVo.setNamedWhereClauseParam("SalaryBind", salaryPgBind.getValue());
            empVo.executeQuery();
        }
    

  • Once value is set in bind variable , view criteria is executed and Search result will be shown in resultant table- Run your application and see
  • To reset values in table and search form, see the managed bean code of Reset button

  •     public void resetButton(ActionEvent actionEvent) {
            searchAMImpl am = (searchAMImpl)resolvElDC("searchAMDataControl");
            ViewObject empVo = am.getEmployees1();
            ViewObject attrVo=am.getattr1();
            empVo.setNamedWhereClauseParam("EmpIdBind", null);
            empVo.setNamedWhereClauseParam("FirstNmBind", null);
            empVo.setNamedWhereClauseParam("EmailBind", null);
            empVo.setNamedWhereClauseParam("SalaryBind", null);
            empVo.executeQuery();
            attrVo.executeQuery();
          
        }
    

  • Click on reset button and page value are set to default

    • This is how we can implement custom search using ADF components, you can apply validations, auto suggest feature etc while using this custom search

    Search Page in ADF

    Search Page in ADF

    You can create search page that allow users to enter search criteria into input fields for known attributes of an object.The search criteria can be entered via input text fields or selected from a list of values in a popup list picker or dropdown list box. The entered criteria is constructed into a query to be executed. Named bind variables can be used to supply attribute values during runtime for the query. The results of the query can be displayed as a table, a form, or another UI component as per need.

    Search page are based either on view criteria defined in view objects or on implicit view criteria defined by JDeveloper. Search pages are region-based components that are reusable and personalizable. They encapsulate and automate many of the actions and iterator management operations required to perform a query.
     You can create several search forms on the same page without any need to change.

    1.Create New Application

      1.Application Name:EmployeeSearch
      2.Application Package Prefix:dilip.oracle.adf.searchEmp

      
      
               
      
           







          








     


     2.Create ADF Business Component(Enity Object,ViewObject,Application Module)

      1.Entity Object:
     
       Name:EmployeeEO
       Package:dilip.oracle.adf.searchEmp.entities
       Schema Object :Employees
       
         



      
      


      Enable Create Method and Remove Method
       
      
        
     Check Generate Default View Object CheckBox
      2.ViewObject:
       Name:EmployeeVO
       package:dilip.oracle.adf.searchEmp.service 

      

     
      Check Application Module CheckBox
      3.Application Module:
       Name:EmployeeAM
       package:dilip.oracle.adf.searchEmp.queries

           

    3.Define Bind Variable:

       Double Click on EmployeeVO in Model  go to query page

       Expand the Bind variable accordion and click on Green button

       Bind Variable name and type as following make sure required check box is un-checked

       Name – empno

       Type -- Number

     

     

    4. Create Named View Criteria

     Double Click on EmployeeVO in Model  go to query page. Expand the View Criteria accordion
      and  click on Green button
     


    View Criteria is actually conditions on VOs which you usually define decoratively

         1.Expand the View Critieria Section in EmployeeVO page and click the Green plus sign

         2.Give a proper name to your View Criteria

           Criteria Name -> EmployeesVOCriteria

         3.Click on Add Item  Click the ( ) group press Add item and select values as sown in slide make sure
           you have selected the   bind    variable empno

              Attribute – Employee_id

              Operator – Equals

              Operand – Bind Variable

              Parameter – empno

              Un-check Ignore Case and Check Ignore Null Values
             
               


        
    6. Create Search Page

    Right Click on ViewController -> New -> Web Tier->JSF/Facelet->Page

    File Name – EmpSearch

    Initial Page Layout and Content – Quick Start Layout

    Click on Browse and select One Column Stretched and check Apply Theme

     



    7.Expand Page Implementation and Select Automatically Expose UI Components in a New Managed Bean

    Select EmployeeVO and Expand the Data Control panel and Drag and drop the Named View Critieria “EmployeesVOCriteria” to the page Choose Query -> ADF Query Panel with Table as shown in Slide.




    8.Change Search Header from "EmployeeEO" to Employee Search
       Change Text Property Search Employee.Also see resulted Search Page.
       

    Friday, February 3, 2017

    Adf Issues

    Unable to reserve the .lok file for Integrated WebLogic Server (IntegratedWebLogicServer).

    Oracle JDeveloper 11.1.2.1
    Windows 7 Enterprise



    When JDeveloper closes unexpected without shutting down IntegratedWebLogicServer, trying to start IntegratedWLS next time, gives "Unable to reserve the .lok file for Integrated WebLogic Server (IntegratedWebLogicServer)."

    First Solution is to kill the process in Task Manager. Open Task Manager & check for java.exe process for higher memory consumption. End the process.

    IF above does not help then go to C:\Users\RRA\AppData\Roaming\JDeveloper\system11.1.2.1.38.60.81\DefaultDomain . Delete the edit.lok file.

    Thursday, February 2, 2017

    s

    SELECT
      l.CUSTOMER_PO_NUMBER
    l.GLOBAL_ATTRIBUTE2
    FROM
      oe_headers_iface_all h,
      oe_lines_iface_all l
    WHERE
      h.CUSTOMER_PO_NUMBER   =l.CUSTOMER_PO_NUMBER
    AND h.sold_to_org_id     ='1296' --Customer_id of customer
    AND l.GLOBAL_ATTRIBUTE2 IN('0078742087306','0078742088341') ;
     --+++++++++++++++++++++++++++++++

    --For delete lines

    DELETE
    FROM
      oe_lines_iface_all
    WHERE
      CUSTOMER_PO_NUMBER IN
      (
        SELECT
          l.CUSTOMER_PO_NUMBER
        FROM
          oe_headers_iface_all h,
          oe_lines_iface_all l
        WHERE
          h.CUSTOMER_PO_NUMBER =l.CUSTOMER_PO_NUMBER
        AND h.sold_to_org_id   ='1296'
      )
    AND GLOBAL_ATTRIBUTE2 IN('0078742087306','0078742088341') ;  --place locations which are deleted.

    Create Simple Search form in Oracle ADF

    Create Simple Search form in Oracle ADF

    1. Create a New Application
    New > Applications > Fusion Web Application (ADF)
    Application Name – SearchForm
    Directory -- (Jdev install dir)/jdeveloper/(project name) 
    Application Package Prefix – Demo.adf.searchform
     

     

     

     

     

     
    2. Create Test Table and insert data some data in it (For Testing Purpose)
    CREATE TABLE xx_search_demo
    (    -- ---------------------
         -- Data Columns
         -- ---------------------
         column1                  VARCHAR2(100),
         column2                  VARCHAR2(100),
         -- ---------------------
         -- Who Columns
         -- ---------------------
         last_update_date   DATE          NOT NULL,
         last_updated_by    NUMBER   NOT NULL,
         creation_date          DATE          NOT NULL,
         created_by               NUMBER   NOT NULL,
         last_update_login  NUMBER
    );
     

    INSERT INTO xx_search_demo VALUES (‘val1’, ’val2’, SYSDATE, 0, SYSDATE, 0, 0);
    INSERT INTO xx_search_demo VALUES (‘val1’, ’val2’, SYSDATE, 0, SYSDATE, 0, 0);
    INSERT INTO xx_search_demo VALUES (‘val3’, ’val4’, SYSDATE, 0, SYSDATE, 0, 0);
    INSERT INTO xx_search_demo VALUES (‘val5’, ’val6’, SYSDATE, 0, SYSDATE, 0, 0); 


      

    3. Create EO
    Right Click on Model > New > ADF Business Components > Entity Object
      

     
    Package -- Demo.adf.searchform.model.entities
    Name – SearchEO
    Schema Object – XX_SEARCH_DEMO
    Note – By default ROWID will be the primary key if we will not make any column to be primary key in Attribute Settings Page  
    Check the Accessors, Create Method, and Remove Method
     

     

     

     

    Check Generate Default View Object CheckBox
    Package – Demo.adf.searchform.model.queries
    Name – SearchVO
     
    Check Application Module CheckBox
    Package – Demo.adf.searchform.model.services
    Name – SearchAM
     
     
     
    4. Define Bind Variables
    Double Click on SearchVO in Model Project go to query page
    Expand the Bind variable accordion and click on Green button
     

     
    Bind Variable name and type as following make sure required check box is un-checked
    Name – Col1
    Type -- String
     
     
    5. Create Named View Criteria
    Double Click on SearchVO in Model Project go to query page. Expand the View Crriteria accordion and click on Green button
     
     
    View Criteria is actually conditions on VOs which you usually define declaratively
         1.      Expand the View Critieria Section in SearchVO page and click the Green plus sign
         2.      Give a proper name to your View Criteria
              Criteria Name -- SearchVOCriteria
         3.      Click on Add Item
               Click the ( ) group press Add item and select values as sown in slide make sure you have selected the bind variable Col1
              Attribute – Column1
              Operator – Equals
              Operand – Bind Variable
              Parameter – Col1
              Un-check Ignore Case and Check Ignore Null Values
     
     
    6. Create Search Form
    Right Click on ViewController > New > Web Tier > JSF > JSF Page
    File Name – Search
    Initial Page Layout and Content – Quick Start Layout
    Click on Browse and select One Column Stretched and check Apply Theme
     
     
     
    Expand Page Implementation and Select Automatically Expose UI Components in a New Managed Bean
    Select SearchVO and Expand the Data Control panel and Drag and drop the Named View Critieria “SearchVOCriteria” to the page
    Choose Query > ADF Query Panel with Table as shown in the slide
     
     
     
     
    The Page would look like this --
     
     
    7. Refine Layout
    Change the Header from “SearchEO” to “Search Demo”. To change select panel Header and change Text property to “Simple Search Demo”
     
    Note - You can change form properties like Column names and page width as per your requirements
     
    8. Congratulation you have successfully finished. Test Your Work Your Simple Search Form is Ready
     
     

    Oracle Fusion - Cost Lines and Expenditure Item link in Projects

    SELECT   ccd.transaction_id,ex.expenditure_item_id,cacat.serial_number FROM fusion.CST_INV_TRANSACTIONS cit,   fusion.cst_cost_distribution_...