Wednesday, 8 May 2013

Auto refreshing a component/page in ADF

Scenario: Refreshing a page automatically after a specified interval.

Solution: 
To acheive the auto refresh feature on a page in ADF we have to use the af:poll. 

Step 1: Use in the jspx.

                       id="pollTimer"
                       pollListener="#{backingBeanScope.backing_stockinfo.onPollTimerExpired}"
                       interval="2000"/>





  • Specify the interval in milli seconds.
  • pollListener is the listener method which will be called every time after the specified interval.
Step 2:In a bean write the poll Listner method which will have the logic to refresh the page.


public void onPollTimerExpired(PollEvent pollEvent) {
         //Custom logic to update the data/data control.
        //Refresh the table/component.
        AdfFacesContext.getCurrentInstance().addPartialTarget(getT1());
  }


  • If we have requirement to refresh different components at different time intervals (like 2mins for a table, 5mins for a graph) then we can implement it by creating variable in view scope which will hold the last updated time and we can check it against the current time, and if the difference exceeds the specified time then we can refresh the component.
  • Below code snippet shows refreshing two tables at two different times (the Alert table will be refreshed after every 2mins and the symbol table will be refreshed after every 5mins.

 public void onPollTimerExpired(PollEvent pollEvent) {
        //Refresh for Alert table.
        Long lastRequery = (Long)AdfFacesContext.getCurrentInstance().getViewScope().get("lastRequery");
      //Updating data control
        ApplicationModule am = ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
        ViewObject alertVO  = am.findViewObject("AlertRO1");
        alertVO.executeQuery();
        AdfFacesContext.getCurrentInstance().addPartialTarget(getT2());

        //Refresh for symbol table.
        if(lastRequery ==null || lastRequery <= System.currentTimeMillis()){
           
            ViewObject symbolVO = am.findViewObject("StockDataViewRVO1");
            symbolVO.executeQuery();
            AdfFacesContext.getCurrentInstance().addPartialTarget(getT1());
            Calendar c=Calendar.getInstance();
            c.add(Calendar.MINUTE, 5);
            AdfFacesContext.getCurrentInstance().getViewScope().put("lastRequery",c.getTimeInMillis());
        }
    }



Sunday, 5 May 2013

Executing custom logic in BPM human task

Scenario: Excuting a custom logic in BPM human task before calling the action of BPM services. 
Let us think that we want some custom logic to be executed on click of Approve/Reject button in BPM human task. 

Solution:
To achieve this, we need to follow the below two steps,

Step 1: Write a managed bean and a submit method and write your custom code first and then the below code to invoke the BPM services.

public String submit(){
       // Custom Logic goes here.............................

        //Invoking BPM Services
                    Map map =
                        FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
                    oracle.bpel.services.workflow.worklist.adf.InvokeActionBean invokeActionBean =
                        (oracle.bpel.services.workflow.worklist.adf.InvokeActionBean)map.get("invokeActionBean");

                    String result = invokeActionBean.invokeOperation();
                     return result;
    }


Step 2: Configure this method as action method in the jspx for the Approve/Reject/Ok button.

                                               text="#{wf:getResourceValue('OK', 'bindings.customActions')}"
                                               disabled="#{!bindings.OK.enabled}"
                                               action="#{pageFlowScope.managedBean.submit}"
                                               partialSubmit="false"
                                               visible="#{wf:isCustomActionAvailable('OK', 'bindings.customActions')}"
                                               id="ctb1">
                       
                                     value="bindings.OK"/>
                     


Monday, 25 February 2013

Clearing the data objects in Oracle BAM

Problem:
The common problem that we all will face in development/testing of  BAM reports is that we may need to reset/clear the values of the data objects.

Solution: 
There is a utility called icommand which we can use to solve the above problem.

go to the bin directory of BAM, (cd /oracle/fmwhome/Oracle_SOA1/bam/bin)

Eg: 
1) clearing data object
icommand -cmd clear -name "path_of_the_dataobject" -type dataobject

path_of_the_dataobject = "/Samples/Call Center/"

2) Deleting the data object

icommand -cmd delete -name TestDO 

Using this icommand we can export the reports/data objects from one BAM server to the another BAM server (please refer to the icommand documentation for usage of specific commands). 

Sunday, 17 February 2013

Creating an LOV which is detached from entity model/DB in ADF


      This post explains how to create an LOV which is detached from entity model (no database or business component validation for insertion should happen on change of the drop down value).


         To demonstrate this, let us consider a login screen which will have user name, password as input text fields and a drop down to select the county whose value will be stored in session for later use (the list of countries should be populated from database but the selection in the UI should not have effect on the database).

1) Let us create a view object for country table.
2) Once the view object is created , Create the LOV for country Id by clicking on attributes à List of values.





3)     In loginpageDef.xml add an executable (iterator).


4) Go to structure of loginpageDef.xml and add variables under executables

5) Create a variable countryIdVar under the variables


6) Now in login.jspx, drag and drop countryName from data controls

7)   Give the proper values (base data source as variables and list data source as data control.

Friday, 15 February 2013

Accessing selected value of LOV (drop down) in ADF

Problem:
How to access the selected value of a LOV (drop down) in managed bean (java class) programatically.

Solution:

1) Write a value change listener for the LOV.
2) Get the Iterator of the LOV from bindings.
3) Get the current select row from the iterator by passing the newly selected value which you can get from the valueChangeEvent object.

Please find the code snippet below,


        BindingContext bctx = BindingContext.getCurrent();
        oracle.binding.BindingContainer bindings = bctx.getCurrentBindingsEntry();


        DCIteratorBinding iterBind = (DCIteratorBinding)bindings.get("CourseVO1Iterator");
        Row rw = iterBind.getRowAtRangeIndex(((Integer)e.getNewValue()).intValue());

        String courseId= rw.getAttribute("CourseId").toString();
        String courseName= rw.getAttribute("Name").toString();

Thursday, 14 February 2013

Error while creating web service proxy from wsdl in Jdeveloper


I am getting the below error while creating the web service proxy in JDeveloper,
oracle.jdeveloper.webservices.model.WebServiceException: Error creating model from wsdl 

I am using Jdeveloper 11.1.1.6.0


Problem:

The problem is in JDeveloper 11.1.1.6.0 (i am not sure about other versions) when you try to create web service proxy in a project which has "ADF Model Runtime" library as a dependency (it is dependent on some other project which has ADF Model Runtime) the proxy creating will fail.

Solution:
Solution 1. Remove the ADF Model Runtime depdency and create web service proxy and then add the dependency again.

Solution 2. Just create an other generic project and create a proxy there and call the proxy.

Solution 3. You can create the web service as a data control in the same project and use it.

Monday, 17 December 2012

Introduction


This blog is just to store/share my learning's especially technology related. My area of technical expertise includes end to end development in java/j2ee (with different frameworks) and currently working on oracle ADF and SOA suite.