Saturday, June 25, 2016

ADF : populating the bind variable from ViewObjectImpl Class

In ADF while working with view objects(Entity based or Readonly) user might be in need to populate the bind variable value from Security context or session scope. for this reason it can be populated easily in java class

Consider a scenario where the query to be executed is "Select * from <tablename> where userid is <logged in user>". Such scenario can be handled via regexs (since i am not very good with regex so i decided to populate such value in java class which gives me flexibility to get such values from security context or session scope and also i can modfiy  the values is needed using java APIs.


Steps.
1. create the bind variable and assign the value as expression as :
adf.object.viewObject.managerRoleIdFromSession





here the managerRoleIdFromSession is private string defined in the Impl class as:


    private String managerRoleIdFromSession;


    public void setManagerRoleIdFromSession(String managerRoleIdFromSession) {
        this.managerRoleIdFromSession = managerRoleIdFromSession;
    }

    public String getManagerRoleIdFromSession() {
        String managerRoleId="";
        Map sessionScope = ADFContext.getCurrent().getSessionScope();
        managerRoleId=sessionScope.get("Manager_roleId")!=null?sessionScope.get("Manager_roleId").toString():"";
        return managerRoleId;
    }

as demonstrated in the setter method user can use the necessary APIs to play around the variable and get desired output

ADF : populating the bind variable from ViewObjectImpl Class

In ADF while working with view objects(Entity based or Readonly) user might be in need to populate the bind variable value from Security context or session scope. for this reason it can be populated easily in java class

Consider a scenario where the query to be executed is "Select * from <tablename> where userid is <logged in user>". Such scenario can be handled via regexs (since i am not very good with regex so i decided to populate such value in java class which gives me flexibility to get such values from security context or session scope and also i can modfiy  the values is needed using java APIs.


Steps.
1. create the bind variable and assign the value as expression as :
adf.object.viewObject.managerRoleIdFromSession





here the managerRoleIdFromSession is private string defined in the Impl class as:


    private String managerRoleIdFromSession;


    public void setManagerRoleIdFromSession(String managerRoleIdFromSession) {
        this.managerRoleIdFromSession = managerRoleIdFromSession;
    }

    public String getManagerRoleIdFromSession() {
        String managerRoleId="";
        Map sessionScope = ADFContext.getCurrent().getSessionScope();
        managerRoleId=sessionScope.get("Manager_roleId")!=null?sessionScope.get("Manager_roleId").toString():"";
        return managerRoleId;
    }

as demonstrated in the setter method user can use the necessary APIs to play around the variable and get desired output