Saturday, 17 September 2022

ADF Advanced

 https://www.udemy.com/course/advanced-oracle-adf-12c-course/

Shared Application Module

  • Create custom application with one model
  • Create adf business objects
  • Define Data Source in application Module(under configurations)
  • Generate ADF library jar file 
    • Project properties -> Deployment (make sure it is ADF Library Jar file)
    • Project -> rightclick-> Deploy -> mysharedModel ->  Deploy to ADF Library JAR file 
    • It creates a Jar file
       
  • Add the jar to main ADF application
    • Create new ADF application 
    • ViewController project ->  Library and Classpaths -> Add Jar/Directory -> select the jar from above step -> 
  • Create Datasource
    • localhost:7101/console (weblogic/weblogic1) -> Services -> Data Sources -> create HRds
    • jdbc:oracle:thin:@localhost:1521:xe

Shared LOVs

  • Lovs in separate application and will be shared by all users
  • They are initialized only once which improves the performance
    • Create custom application with one model
    • Create view objects which will be used in LOVs
    • Define data source in AM
    • Create Application Module instance from Project properties
      • Project Properties -> Application Module Instances -> select AM by shuffling to right with cache at Application/session level
    • Generate ADF library jar file 
    • Add jar to main ADF application model project
      • When navigated to attribute LOV of any view Object -> add -> view Usage (instead of view definition)

Cascaded Lovs

  • Create all VOs which will be used as LOVs
  • Create view criteria in all VOs which will be filtered
  • Create LOV over each attribute and pass parameter to criteria
  • set autosubmit & dependencies in the view object attributes
  • set autosubmit & partial triggers on the jsf page

LOVs Switcher

  • Create all VOs which will be used as LOVs
  • Create view criteria in all VOs which will be filtered
  • Create 2 LOV for an attribute and set one of them as default
  • Accessors -> Attach view criteria to the LOVs
  • Create transient attribute which will be used as Switcher
  • Configure the transient attribute getter to return lov name depending on specific condition
  • Set autosubmit & dependencies in view object attributes
  • set auto submit and partial triggers in jsf page  

Method Validations

  • Entity Objects -> Business Rules
  • Right click on Entity Validator or Attribute Validator
  • Select type as "Method" and write error message in Failure Handling Tab
  • Entity Impl -> write code
  • The method should return True or False

Extended View Object

  • Create View object -> extends -> Existing view object
  • It will extend all attributes, LOVs, EO configurations
  • After creating new VO, one can add new attributes &  change where clause
  • No changes can be made to extended attributes

Client Interface Methods

  • Am.java -> create public method
  • AM -> client interface -> shuffle the method
    • ViewObjectImpl deptVO = getDepartmentsView1();
      ViewCriteria vc = deptVO.createViewCriteria();
      ViewCriteriaRow vcr = vc. createViewCriteriaRow();
      vcr.setAttribute("DepartmentId", arg1);
      vc.addRow(vcr);
      deptVO.applyViewCriteria(vc)
      deptVO.executeQuery();
      while (deptVO.hasNext()){
          Row r =
      deptVO.next();
          return r.getAttribute(arg0);
      }
  • viewImpl.java -> create public method
    View -> client interface -> shuffle the method
    Key key =new Key(new Object[] {employeeId});
    Row r = this.findByKey(empKey, 1)[0];
    String fullName = r.getAttribute("FirstName")+ " "+ r.getAttribute("LastName");
    return fullName;

View Object instance map to view

Groovy Expressions
  • Master Detail relation ship- accessing child from master
    • Create accessor
    • Transient Attribute on master -> expression -> accessor.count(attribute)
  • Access parent attribute
    • Transient attribute on Chile -> expression -> accessor.attributeName
  • Within same entity
    • New transient attribute -> expression -> firstName + “ “ + lastName
    • If ((salary !=null) && (comm!=null)) {
    • Salary + comm } else salary;
  • Default values
    • Adf.currentDate
    • Adf.currentDateTime
Bind Variables & overriding methods
  • Groovy expression to refer java class method that returns bind param value
    • <package>.<class>.<method>
  • ViewImpl.jab -> override method prepareRowSetForQuery to set bindVariable prior to super() call
  • Bind Variable in ViewCriteria
    • ViewImpl.java -> custom method -> getViewCriteria-> set bind param value -> apply view criteria -> execute query 
    • Expose the method as client interface OR call from backing bean

Overriding methods

ADF Logger

https://www.youtube.com/watch?v=0ghJ3CUjI_Y

 

  • System.out.println
    • You have to remember to remove it
    • no granularity
    • goes only to one place
    • It is meant for appln user and not for developer/admin
     
  •  thin Wrapper on top of java.util.logging
  • private Static Logger logger = Logger.createADFLogger(<classname>);
    • logger.info("information");  //config/severe/warning/info
  • private static ADFLogger _logger = ADFLogger.createADFLogger(ItemEOImpl.class);
    // in setters
       _logger.info("adf");
    Switch logging ON
       integrated weblogic server -log -> Actions -> configure Oracle Diagnostic Logging -> + Give logger name & logger level
  • run application
  • integrated weblogic server -log -> Actions -> analyze logs -> current in console -> by log message -> filter as needed
  • Logging on ADF core classes
    • https://www.youtube.com/watch?v=0ghJ3CUjI_Y
  • Debugger
  • https://www.youtube.com/watch?v=rV9U1wlLevU
     

 

IDCS: https://www.youtube.com/watch?v=HY1rVixlcPo&t=618s

Diagnostics Logging -> https://www.youtube.com/watch?v=FxA2Fs0zhAM&t=219s

  • It allows seeing ADF Business components methods, arguments, sql queries and so
  • Add diagnostics to Java options
    • -Djbo.debugoutput
    • -Djbo.logging.show.function
    • -Djbo.logging.show.timing
  • Model project -> properties -> Run/Debug/Profile -> edit run configurations ->
  • -Djbo.debugoutput=console -Djbo.logging.show.function=true -Djbo.logging.show.timing=true
  •  To move the logs to file
    Tools ->preferences -> log -> save logs to file

No comments:

Post a Comment