Thursday, 27 February 2020

ADF

Application Module
  • Expose view instances to UI/View layer.
  • Assign view criteria to view instances
  • Java classes
  • Configuration 
    • Datasource that is used when the application is deployed to weblogic server
    • Define pool configuration
  • Run and test the Application module
  • Java
    • It has all view object instances exposed to View Layer
    • Create your own business function and expose to view layer
    • Override afterCommit & afterCommit methods
    •  
Association
  • Connection/Link between two entities
View Link
  •  Link between two View Objects
  • It can be defined on view attributes OR on top of Association defined at entity level

ADF Logger
https://www.youtube.com/watch?v=o-2r-Max3II
http://tinyurl.com/adf-logging
  • 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");

View Objects
  • Entity Based
  • SQL Query based
  • Static list
  • Programmatic
    • VO which is not based on query. One can define VO attributes and insert rows at runtime
    • Generate javaimpl & javarowimpl  
    • bind the ui elements to backing bean

View Criteria
  1. Filtering the main view data
  2. Search page
  3. List of Values input - > assign criteria
Java Code ->  Source -> override methods
  1. viewImpl.java
    1. executeQueryForCollection() -> set bind variable before the super method
    2. change sql
  2. viewRowImpl.java  (like entity object)
    1. Create()
    2. Remove()
View Layer
  • Application
  • Session
  • PageFlow 
  • Request
  • Backing bean
  • view
  • none
LOV Types:
  • Single Selection
    • ADF Select One Choice
    • ADF Select One Listbox
    • ADF Select One Radio
    • ADF Select Boolean Checkbox 
  • List Of Values
    • ADF LOV Input
    • ADF LOV Choice List
Client Side LOV
  • Create a new VO Attribute say InvoiceCurrencyCodeCsLOV
  • Add LOV as ComboLOV to the newly created attribute
  • Add custom attribute ListType and set value to inputSearch
  • Also, add LOVResource property and set values
  • Drag and drop Switcher & two facets within it
  • Drag the new attribute as LOV onto the page within Switcher facet. Delete the code generated as we use the wrapper API.
  • Infplace of deleted code, Drag FinClientSideLOV onto one facet and provide following properties
    • BusinessObject
    • LOV Binding
    • Value 
    • valueAttribute
  • Drag regular LOV code onto other facet
  • Optin stategy
    • Profile FUN_CLIENT_LOV_ENABLED to yes
    • To disable for AP incase of any errors, create Lookup Type 'AP_NEW_FEATURES' with lookupcode 'AP_DISABLE_CLIENTSIDE_LOV'

View Layer
 Table & Panel Collection

  • Make the table stretchable & with same width equally for each column
    • Table Properties -> Appearance -> Column Stretching ->Multiple
    • Appearances -> Set the width to 33% for all columns 
  • Display icon to clear table filters
    • Create a new column & set width as 14, rowHeader to True
    • Show index(rownum) for the rows in the header column
      • Insert output text under the rowHeader column
      • set the value property to #{row.index}
  • Table -> context menu
    • Table -> insert ContextMenu facet
    • insert popup -> Menu -> Menu item
  • Table -> Detail Stamp
    • Drag the child table
    • Table properties -> Behavior ->  RowDisclosureListner -> associate backing bean methold
      public void rowListner(RowDisclosureEvent rowDisclosureEvent){
      <<logic here>>
      }
  • Panel Collection features
    • Detach -> to show table in full screen
    • Control table filter
    • Control the Visible/hide columns 
    • Sorting & reorder columns
    • Column selection multiple -> Freeze & Wrap features can be used
    • Features OFF -> To disable certain features
REST
How to invoke Exposed REST service
Validator
  • Custom Validation at EO level
    • EO-> Business Rules-> Attribute level or entity level -> new validator -> method -> error message in failure handling tab 
    • java impl -> write the code in generated method -> the method should return true or false.
Converter
  • Store data in database in specific format but user should see it and enter it in different format.
  • Create a java class implementing javax.faces.convert.Converter
  • The interface has 2 methods getAsObject & getAsString. First one is to set the value & second one for getting
  • public Object getAsObject(FacesContext facesContext, UIComponent uIComponent, String str){
    if (str.length!=10)
    {
    FacesMessage message = new FacesMessage("incorrect length");
    message.setSeverity(FacesMessage.SEVERITY_ERROR);
    throw new ConverterException(message);
    }
    return "+91"+substr(str,1,11);
    }
  • public Object getAsString(FacesContext facesContext, UIComponent uIComponent, Object obj){
    String value = String.valueOf(obj);
    return "0"+substr(str,2,12);
    }
  • Register the class with faces-config -> Converters
  • How to apply converter to UI field
    • Input text item -> insert converter -> select the registered converter
    •  
BLOB - Uploading/downloading in ADF applications
  • Drag af:InputFile to toolbar
  • af:InputFile -> Value Change Listner -> add bean  method -> uploadImage
    public void uploadImage(ValueChangeEvent valueChangeEvent){
    UploadFile file = (UploadFile) valueChangeEvent.getNewValue()
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingEntry();
    DCIteratorBinding iter = () bindings.get("iteratorname");
    iter.getCurrentRow.setattribute("empimage", new BlobDomainForInputStream(file.getInputStream));
  • private BlobDomain newBlobDomainForInputStream(InputStream in){
    BlobDomain b = new BlobDomain();
    OutputStream o = b.getBinaryOutputStream();
    writeInputStreamtoOutputStream(i,o);
    }
  • private void writeInputStreamtoOutputStream(InputStream i, OutputStream o){i.close();
    byte[] buffer = new byte[8192];
    int bytesRead = 0;
    while ((byteRead=in.read(buffer,0,8192))!=-1) {
    out.write(buffer,0,byteRead);
    }
UI Components
  •  Panel box
    • Add content with a label/title
    • Has toolbar facet
    • It has DisclosureListner property for programatic control
    • Key properties
      • maximize property to show/hide the maximize icon
      • showDisclosure Property
      • Disclosed property
  • Panel Group layout
    • Layout property to select Vertical vs Horizontal
    • Valign property
Listners
  •  LOV
    • ValueChangeListner
    • LaunchPopupListner -> before popup is launched
    • ReturnPopupListner ->
  • TableSelection
    • SelectionListner
  • Popup
    • PopupFetchListner -> just before popup opens
    • PopupCancelListner ->
Classic Session Based Authentication: 
  • Client authenticates with server using user/passwd for the first time
  • Server creates a session and returns token
  • Client stores the token in cookie and sends the token in all subsequent requests.
REST APIs
  • REST is stateless - Server doesn't save any data that persists across requests.
  • Session based authentication doesn't work
  • Basic Auth(Credentials are sent in header for every request)
    • Client authenticates with server using user/passwd in every request.
    • Username & password is sent as part of request header in specific format
      • username:password and Base64 encode 
      • Authorization: Basic <encoded string>
    •  On server side-> system does base64 decoding
    • Encode string is not secure. Hence, send it over https protocol
    • Encoding is to make string HTTP compatible
    • Advantages
      • Simple, stateless & supported by all browsers
    • Disadvantages
      • Requires https
      • subject to replay attacks
      • logout is tricky(browser caching)
  • Digest access authentication
    • Encrypts and sends a secret
  • Asymmetric cryptography
    • public-private key cryptography
  • OAuth 
    • It is meant for Authorization
    • It is meant for service to authorize another service
    •  
  • JSON web tokens
Tuning and control weblogic memory
  • Jdev -> tools-> preferences-> file types-> default editor -> source
  • Jdev -> tools-> preferences->Code editor -> Save actions -> delete the build project on save option
  • Increase memory allocation for jdev editor
    • OS location where Jdev is installed -> jdeveloper -> ide -> bin ->  ide.conf -> add VM option 
  • Increase memory allocation for embedded weblogic server
    • help -> about -> properties -> configuration area property -> get os folder name -> DefaultDomain -> bin -> setDomainEnv.cmd ->

Friday, 21 February 2020

Shared Application Module

  1. Create custom application with one module
  2. Create all ADF BC components
  3. Define datasource in application module
  4. Model project -> generate ADF library jar file
  5. Add the jar to main ADF application