Sunday, April 28, 2013

How to invoke backing bean method right after page fragment loads


Usecase : Invoke a backing bean method right after page fragment loads and access the UI components rendered on the page fragment

Implementation : 

 - Create a backing bean implements oracle.adf.model.RegionController class
- override isRegionViewable(), getName(), refreshRegion(),validateRegion() as shown below

    - Configure the class which implements to RegionController in pageFragment page definition file as shown below.

Friday, April 26, 2013

ADF Practice/Workshop Assignments - Real time scenarios

The intention of this blog is to get some hands on practice with complex & real time scenarios in day to day basis you encounter.

Scenario #   Invoke a backing bean method by passing some input parameter while loading af:table component

       - <af:table> component binds to Updatable View object and it has 5 columns with <af:inputText> components
      - invoke a method in backing bean for 'readOnly' attribute of each inputText component and pass the corresponding label name to backing bean, Have some condition(any) in the backing bean in such a way that , the method will return true/false based on passed label Name

Scenario # Invoke a backing bean method using clientListener and ServerListener

   - Have a jspx page with variety of UI components, on page Load invoke a backing method using clientListener, serverListener and have the logic in backing bean to disable all the UI components.

Scenario #  Customize <af:table> component Filter Criteria.

 - af:Table component binds with a view object and has some date columns.
 - User will enter the value for one of the date column top line filter as 03/13/2013 +2 , Filter the table based on corresponding top line filter value by adding two days to the given date.

Scenario #  Invoke a backing bean method whenever browser window closed.

- Invoke a method in backing bean just before page fragment loads, Invoke a backing bean method whenever use close the browser window.

Scenario #  TabNavigation

- jspx page with three tabs, each tab associated with a unbounded taskflow used as a <af:region>.
   If user selects 'tab2' , Display a popup message with 'Yes/No' buttons, If user select 'Yes' then retain the user on same tab i.e 'tab1' , If user selects 'No' then allow the user to navigate to 'tab2'

Tuesday, April 23, 2013

Jdeveloper, Oracle XE Installation Steps.


Oracle JDeveloper    This Integrated Development Environment(IDE) provided by Oracle, Allows to build simple to large scale applications.

If it prompts for OTN user id and password, Register with your own email id and use

URL : http://www.oracle.com/technetwork/developer-tools/jdev/downloads/jdeveloper11116-1377208.html
Download Studio Edition 11.1.1.6.0  and install.

Oracle 11g Express Edition Database (XE)    : Light weight database provided by Oracle.

URL : http://www.oracle.com/technetwork/products/express-edition/downloads/index.html
Accept the License agreement, Download and install on your machine, Remember the password you give during installation

Remote Desktop Sharing using Chrome :   Google Chrome has best feature, that you can share /access remote desktop without setup/installation of any software

Step 1 : Open below URL in your chrome browser
https://chrome.google.com/webstore/detail/chrome-remote-desktop/gbchcmhmhahfdphkhkmpfmihenigjmpp/related
Step 2 :  If it prompts for installing any plug-in's, Install those. Click on ' LAUNCH APP' (Green color button)
Step 3:  To Share the desktop, Click on 'Share' button, and pass the access code to partner.
Step 4 : To Access remote desktop, Click on 'Access' button and get the access code from the partner.




Wednesday, April 17, 2013

Jdeveloper Shortcuts



Below are the list of shortcuts most commonly used in Jdeveloper.


Find Usages Ctrl+Alt+U
Go To Java Type Ctrl+Minus
Go To File Ctrl+Alt+Minus
Show Overview Ctrl+Shift+ Back Quote
Extract Method Ctrl+Alt+X
Introduce Variable Ctrl+Alt+V
Run Project F11
Debug Project Shift+F9
Quick JavaDoc Ctrl+D
Reformat Ctrl+Alt+L
Code Highlight Ctrl+Alt+H
Clear Code Highlight Ctrl+Alt+K
Structure Ctrl+Shift+S
Property Inspector Ctrl+Shift+I
Component Palette Ctrl+Shift+R
Break Point Ctrl+Shift+R
Copy Path Ctrl+Shift+C
Go To Line Ctrl+G
Go To Window Ctrl+F6
Go To File Ctrl+Alt+Minus
Make Project Ctrl+F9
Rebuild Project Alt+F9
Resume F9
Step Over F8
Step Into F7
Step Out Shift+F7
Java Editing
Organize Imports Ctrl+Alt+O
Select in Navigator Alt+Home

Debug Project Shift+F9
Show Overview Ctrl+Shift+ Back Quote
Find Usages Ctrl+Alt+U
Go To Java Type Ctrl+Minus
Go To File Ctrl+Alt+Minus
Extract Method Ctrl+Alt+X
Introduce Variable Ctrl+Alt+V
Run Project F11
Quick JavaDoc Ctrl+D
Reformat Ctrl+Alt+L

Search
Code Highlight Ctrl+Alt+H
Clear Code Highlight Ctrl+Alt+K
Auto Code Highlight (this makes the code always highlighted)

View
Structure Ctrl+Shift+S
Property Inspector Ctrl+Shift+I
Component Palette Ctrl+Shift+R
Break Point Ctrl+Shift+R

Miscellaneous

Copy Path Ctrl+Shift+C
Go To Line Ctrl+G
Go To Window Ctrl+F6
Go To File Ctrl+Alt+Minus

Build
Make Project Ctrl+F9
Rebuild Project Alt+F9

Run
Resume F9
Step Over F8
Step Into F7
Step Out Shift+F7

Java Editing
Organize Imports Ctrl+Alt+O
Select in Navigator Alt+Home

Path for jdev.conf  : C:\Oracle\Middleware1117\jdeveloper\ide\bin
Path for ide.conf : C:\Oracle\Middleware1117\jdeveloper\jdev\bin

Add Below property

AddVMOption  -Xmx640M
Ref : https://blogs.oracle.com/shay/entry/jdeveloper_keyboard_shortcuts

Tuesday, April 9, 2013

How to Create a Custom Filter Class in Coherence

Usecase :  How to query Coherence cache using Custom created filters. By default Coherence API provides variety of filters like AndFilter, OrFilter, EqualsFilter, etc. You might have a requirement to create a custom Filter and use this filter to query cache.

Implementation:

Create a Custom Filter class , which implements Filter and PortableObject interfaces as shown below. This class must override evaluate method and which contains the filter logic. Make sure to add annotation to below class as @Portable



After creating Custom Filter class, Configure this in pof-config.xml as shown below. Make sure type-id must be unique in this file.
Finally, query the coherence cache as shown below using newly created custom filter.

Monday, April 8, 2013

How to Apply MDS to ADF Application


MDS - Meta Data Service, is one of the powerful feature provided by Oracle, This will allow to store user specific defaults into MDS and can be retrieved whenever needed.

Below blog clearly explains about how to configure MDS to an ADF application
http://sameh-nassar.blogspot.com/2012/03/apply-mds-to-oracle-adf-application.html

Tuesday, April 2, 2013

Get all the selected rows ADF table in backing bean

Requirement: We have a table with multiple row selection enabled and we have to get all the selected rows in the backing bean

Note: In this example we are using user portfolio in stock management application

Steps:

1. Add an accessor in the backing bean and bind it to the table as below



2. Drag and drop adf button in the jspx page with the table <af:table> as below.



3. Bind a backing bean method to the above button created as below



4. Write the following code in the backing bean and you have to import the following packages

import java.util.Iterator;
import java.util.List;
import javax.faces.event.ActionEvent;
import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCBindingContainer;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.component.rich.data.RichTable;
import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.RowSetIterator;
import org.apache.myfaces.trinidad.model.RowKeySet;

    public void getSelectedRows(ActionEvent actionEvent) {
        // Add event code here...
        RowKeySet selectedEmps = getPfTable().getSelectedRowKeys();   
        Iterator selectedEmpIter = selectedEmps.iterator();
        DCBindingContainer bindings =
                          (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding empIter = bindings.findIteratorBinding("PortfolioStocks2Iterator");
        RowSetIterator empRSIter = empIter.getRowSetIterator();
         while(selectedEmpIter.hasNext()){
           Key key = (Key)((List)selectedEmpIter.next()).get(0);
           Row currentRow = empRSIter.getRow(key);
           System.out.println(currentRow.getAttribute("Stockid"));
         }
         //return null;
    }

 5. Get the iterator to be bound from the page definition as below