Thursday, January 30, 2014

Most used ADF security EL expressions


EL expressions for ADF Security

We can use them any where in the ViewController side to check various security aspects

- #{securityContext.authenticated}               => get the user's authentication state
- #{securityContext.userName}                    => get the user's Name
- #{securityContext.userInRole['roleList']}      => get the role memberships, permissions
- #{securityContext.userInAllRoles['roleList']}
- #{securityContext.taskFlowViewable['target']}  => get the user's permission to access to taskflow
- #{securityContext.regionViewable['target']}   => get the user's permission to access a page
- #{securityContext.userGrantedResource['permission']}  
- #{securityContext.userGrantedPermission['permission']}

Memory scopes explained in Oracle ADF

Application:
- Will last as long as any user working with the application exists
- Whatever is put into this scope is available to all the users
- Some configuration data that could be shared across all the users

Session
- Exists for the duration of the user working with an application
- Exists from the time of creation to the time they are deleted or session is closed
- Attributes are the user instance specific for example user name

PageFlow - ADF Specific Scope
- Every taskflow (bounded, unbounded) has the pageflow scope
- Lasts as long as the taskflow is active
- Unbounded taskflow lasts as long as the application is active = Session but some exceptions
- If we are calling a bounded taskflow from unbounded taskflow,
then the pageflow scope of the unbounded taskflow is suspended and put in the stack and recovered later
- It is always dedicated to the taskflow that I am currently in
- Parent TaskFlow's PageFlow scope can't peak into the called bounded taskflow's Pageflow scope and vice versa

View
- Will last as long as the page is alive here, for example we could send multiple request from the same single page
- Even on redirecting to the same page will keep the view scope alive
- Temp info that we use on a specific page that to be kept between requests
 The object is available until the ID for the current view changes. 

Request
- Client pinging the server and server responding to the server is the duration

BackingBean Scope
A backing bean is a convention to describe a managed bean that stores accessors for UI components and event handling code on a JSF page.
- It exists for the duration of a request and should not be used to maintain state.
- Same duration as that of request
- Special Case of the request scope
- Associated with specific managed bean instance
This is needed because there may be more than one page fragment or declarative component on a page, and to avoid collisions between values, any values must be kept in separate scope instances. 

How to convert java.util.Date to oracle.jbo.domain.Timestamp


In most of the scenarios, the date selected on the UI is of the format java.util.Date but the column store in the database will be of the format oracle.jbo.domain.Timestamp.




Convert Date to Timestamp

java.util.Date dateObj;
oracle.jbo.domain.Timestamp timestampObj = new oracle.jbo.domain.Timestamp(dateObj);



Convert Timestamp to Date

oracle.jbo.domain.Timestamp timestampObj;
java.util.Date dateObj = new java.util.Date(timestampObj.getTime());

How to configure SelectOneChoice top line filter for component in ADF ?

This blog explains about defining <af:selectOneChoice> component in a top line filter in <af:table>

Scenario : For example, We are storing employee ID's into database table, but in table we are displaying employee Names instead of ID's , View Object contains only employee ID's , If user tries to filter table by employee name it will not show any results, because filter criteria applies against  ID's. To resolve this issue, we can display a list of employee names in a top line filter as SelectOneChoice or SelectManyChoice components, Display  Names as 'Label' and Employee ID's as 'Value' , User can select any employee name in a list and hit enter it filter the table based on selected employee ID and display the corresponding results.

Implementation

- Below is the screenshot how it looks like after implementing SelectOneChoice component as a topline filter

User can select any one of the employee as shown below

-Define the View Object at Ammplication Module Level, In this example, I am going to display MarketingCoordinatorLOV which is already configured in my App Module. Define tree binding in corresponding page definition as follows.


-Below is how code looks like in page fragment, unselectedLabel ="" shows blank label.




Saturday, January 25, 2014

How to find Dirty Transaction check in Backing Bean

This blog explains about getting Application Module instance in backing bean and finding whether there is dirty transaction or not.


// Below code is used to get the Application Module instance in backing bean using DC Iterator bindings. This is best way of getting AM Instance in backing bean, This is not going to create a new AM instance.

        DCBindingContainer bindings =
            (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DataControl dc =
            bindings.findDataControl("EmployeeServiceDataControl");
        ApplicationModuleImpl am =
            ((ApplicationModuleImpl)dc.getDataProvider());  

// EmployeeService - This is application module name.  
// Below code is used to determine whether there is any dirty transaction data or not.
                  boolean isDirty =am.getDBTransaction().isDirty();


Tuesday, January 21, 2014

How to install Oracle Virtual Box on Windows7 platform?

This blog explains about installing Oracle Virtual machine on Windows7 Operating system, Also explains about installing multiple IE(Internet Explorer) browser versions on a single machine using Oracle Virtual Machine.

Download and install Oracle Virtual box

https://www.virtualbox.org/

Download Windows IE version Virtial box software from the below link

http://www.modern.ie/en-us/virtualization-tools#downloads

- Select the Desired Testing OS from the available options (Eg : Windows)
- Select Virtualization Platform ( Virtual box on Windows)
- Screen should like as below
- Download the respective IE&Windows OS Virtual box software. For instance, I downloaded IE8-Win7 and IE9-Win7 , It may take a while to download these s/w.
- Install Oracle Virtual Box and above IE Windows virtual s/w on your machine.
- Launch 'Oracle Virtual Box' software on your machine upon successful installation.
- Note : It may prompt you to enable 'Virtualization' option on your machine using BIOS setting. BIOS settings are very sensitive, make sure you modify this correctively
   - Re start Windows OS , Press (F1) key to goto BIOS Settings just before OS begins loading. This may vary from Operating system to Operating system, Careful before modifying any of these settings, I am not responsible for any failures with respect to BIOS settings.  Once you see BIOS settings

- Below is how Oracle Virtual Box Manager window looks like, Choose 'Start' arrow to launch Windows Virtual Machine.


- That's all you need to do to install Oracle Virtual Box  and Windows virtual machines.

Thursday, January 2, 2014

How to make ADF Form fields read only based on some status in ADF ?


This blog explains about how to make ADF  Form fields read only based on some condition

Solution :

-  Override isAttributeUpdatable(int)  method in respective VO Row Impl class as shown below

- Below is how screen looks like after implementing above change.