ADF Code Corner. 92. Caching ADF Web Service results for in-memory filtering. Abstract: twitter.com/adfcodecorner



Similar documents
ADF Code Corner. 66. How-to color-highlight the bar in a graph that represents the current row in the collection. Abstract: twitter.

ADF Code Corner How-to pass values from a parent page to a popup dialog. Abstract: twitter.com/adfcodecorner

ADF Code Corner Building a search form that displays the results in a task flow. Abstract: twitter.com/adfcodecorner

ADF Code Corner. 77. Handling the af:dialog Ok and CANCEL buttons. Abstract: twitter.com/adfcodecorner

ADF Code Corner. 81. How-to create master-detail behavior using af:paneltabbed and DVT graph components. Abstract: twitter.

Building and Using Web Services With JDeveloper 11g

Building an Agile PLM Web Application with JDeveloper and Agile 93 Web Services

Tutorial on Building a web Application with Jdeveloper using EJB, JPA and Java Server Faces By Phaninder Surapaneni

ADF Code Corner Drag-and-drop reordering of table rows. Abstract: twitter.com/adfcodecorner

ADF Code Corner. 86. Reading boilerplate images and icons from a JAR. Abstract: twitter.com/adfcodecorner

Developing Rich Web Applications with Oracle ADF and Oracle WebCenter Portal

Oracle Technology Network Virtual Developer Day. Developing RIA Web Applications with Oracle ADF

The Oracle Fusion Development Platform

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

ADF Code Corner ADF Faces RC - How-to use the Client and Server Listener Component. Abstract: twitter.com/adfcodecorner

This presentation is for informational purposes only and may not be incorporated into a contract or agreement.

Java Access to Oracle CRM On Demand. By: Joerg Wallmueller Melbourne, Australia

Developing SQL and PL/SQL with JDeveloper

Publishing, Consuming, Deploying and Testing Web Services

Tutorial: Mobile Business Object Development. SAP Mobile Platform 2.3 SP02

Tutorial: Mobile Business Object Development. SAP Mobile Platform 2.3

Getting Started with Telerik Data Access. Contents

ORACLE BUSINESS INTELLIGENCE WORKSHOP

An Oracle White Paper September Oracle Team Productivity Center

When a business user interacts with an integrated workbook, there are various elements involved in the picture. Each of these elements has its own

Integrating SalesForce with SharePoint 2007 via the Business Data Catalog

OTN Developer Day: Oracle Big Data. Hands On Lab Manual. Introduction to Oracle NoSQL Database

Tutorial: Mobile Business Object Development. Sybase Unwired Platform 2.2 SP02

ER/Studio Enterprise Portal User Guide

PTC Integrity Eclipse and IBM Rational Development Platform Guide

Oracle Fusion Middleware

<Insert Picture Here> Building a Complex Web Application Using ADF and Siebel

JBoss SOAP Web Services User Guide. Version: M5

Oracle Hyperion Financial Management Developer and Customization Guide

Web Services API Developer Guide

This guide provides step by step instructions for using the IMF elibrary Data - My Data area. In this guide, you ll learn how to:

Web Intelligence User Guide

HOWTO SAP SECURITY OPTIMIZATION WITH SAP SOLUTION MANAGER

DocuSign for SharePoint

MailEnable Connector for Microsoft Outlook

SOS SO S O n O lin n e lin e Bac Ba kup cku ck p u USER MANUAL

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

Oracle Hyperion Financial Management Custom Pages Development Guide

Oracle Web Service Manager 11g Field level Encryption (in SOA, WLS) March, 2012

ITS. Java WebService. ITS Data-Solutions Pvt Ltd BENEFITS OF ATTENDANCE:

<Insert Picture Here> Betting Big on JavaServer Faces: Components, Tools, and Tricks

Tutorial on Operations on Database using JDeveloper

Generating Open For Business Reports with the BIRT RCP Designer

Visualization with Excel Tools and Microsoft Azure

ORACLE BUSINESS INTELLIGENCE WORKSHOP

Module 13 Implementing Java EE Web Services with JAX-WS

Global Preview v.6.0 for Microsoft Dynamics CRM On-premise 2013 and 2015

WA2087 Programming Java SOAP and REST Web Services - WebSphere 8.0 / RAD 8.0. Student Labs. Web Age Solutions Inc.

AWS Schema Conversion Tool. User Guide Version 1.0

Chapter 4: Website Basics

TIBCO Silver Fabric Continuity User s Guide

How To Use Query Console

Working with WebSphere 4.0

NetIQ. How to guides: AppManager v7.04 Initial Setup for a trial. Haf Saba Attachmate NetIQ. Prepared by. Haf Saba. Senior Technical Consultant

Data Crow Creating Reports

Business Objects Version 5 : Introduction

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Oracle Business Intelligence 11g OPN Advanced Workshop

Global Search v 6.1 for Microsoft Dynamics CRM Online (2013 & 2015 versions)

SAP BusinessObjects Design Studio Overview. Jie Deng, Product Management Analysis Clients November 2012

Business Objects. Report Writing - CMS Net and CCS Claims

Developing Java Web Services

1. Tutorial Overview

Developing Web and Mobile Dashboards with Oracle ADF

Importing TSM Data into Microsoft Excel using Microsoft Query

<Insert Picture Here> Oracle SQL Developer 3.0: Overview and New Features

Release Document Version: User Guide: SAP BusinessObjects Analysis, edition for Microsoft Office

Creating XML Report Web Services

Acrolinx IQ. Acrolinx IQ Plug-in for Adobe CQ Rich Text Editor Installation Guide Version: 2.9

Enterprise Service Bus

Oracle Enterprise Manager

FUSE-ESB4 An open-source OSGi based platform for EAI and SOA

Using IBM dashdb With IBM Embeddable Reporting Service

Don t get it right, just get it written.

ADF Code Corner How-to drag-and-drop data from an af:table to af:tree. Abstract: twitter.com/adfcodecorner

MICROSOFT OUTLOOK 2010 WORK WITH CONTACTS

Creating and Using Databases with Microsoft Access

Whitepaper ADF Performance Monitor Measuring, Analyzing, Tuning, and Controlling the Performance of Oracle ADF Applications

Publishing Geoprocessing Services Tutorial

IBM BPM V8.5 Standard Consistent Document Managment

Internet Explorer 7. Getting Started The Internet Explorer Window. Tabs NEW! Working with the Tab Row. Microsoft QUICK Source

RDM+ Remote Desktop for Android. Getting Started Guide

Microsoft Access 2007

AWS Schema Conversion Tool. User Guide Version 1.0

Java EE 7: Back-End Server Application Development

Administering Jive for Outlook

1 What Are Web Services?

J j enterpririse. Oracle Application Express 3. Develop Native Oracle database-centric web applications quickly and easily with Oracle APEX

Analyzing Excel Data Using Pivot Tables

Access 2010: The Navigation Pane

INTEGRATING MICROSOFT DYNAMICS CRM WITH SIMEGO DS3

1 What Are Web Services?

Transcription:

ADF Code Corner 92. Caching ADF Web Service results for in-memory Abstract: Querying data from Web Services can become expensive when accessing large data sets. A use case for which Web Service access can be avoided is when table data as it can be done in memory. In Oracle ADF, you access Web Service from JAX-WS proxy clients or the Web Service Data Control. While the Web Service data control does not allow to intercept data queried from Web Services, the jax-ws proxy client does. This article shows how to use the JAX-WS client proxy with Oracle ADF to access Web Service and locally cache data for further data operations. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 31-OCT-2011

Oracle ADF Code Corner is a loose blog-style series of how-to documents that provide solutions to real world coding problems. Disclaimer: All samples are provided as is with no guarantee for future upgrades or error correction. No support can be given through Oracle customer support. Please post questions or report problems related to the samples in this series on the OTN forum for Oracle JDeveloper: http://forums.oracle.com/forums/forum.jspa?forumid=83 Introduction In the example, an EJB based Web Service queries data of the Employees table in the HR schema to display in an ADF bound table. The table is configured to allow users to filter the displayed data by typing search conditions into the search fileds shown in the column headers. Filtering the table data results in another query sent to the web service. In the example however, both the search filter fields in the column headers and the custom filter field accessing a method exposed on the data control filter the table data in memory, meaning that no request is sent to the webservice. 2

Building the Web Services Proxy Client To be able to cache the queried Web Service data displayed in the table, a JAX-WS proxy client is needed to read the data from the Web Service. The proxy client is then accessed from a POJO bean that becomes the ADF Data Control application developers work with. This way, developers get a chance to intercept the Web Service request and response and also protect custom code from the impact of re-generating the proxy client (which may be required when the remote Web Service API changes). To create a Web Service client proxy, create a new Oracle JDeveloper project and configure it for Web Service support. Select the project, JaxWsPrxyModelDC in the example, and choose New from the right mouse context menu. In the opened New Gallery select Business Tier Web Service Proxy and press Ok. In the second dialog of the web Service proxy creation wizard, add the WSDL reference of the remote Web Service. 3

Note: The Web Service in the example is created from an EJB business service created in the Model project. In a real scenario, the Web Service would be remote and not contained in the application itself (for demoing Web Services however, it is quite convenient) In the following dialog, define a base package and special "types" package for the Java artifacts that are getting created based on definitions in the WSDL file. This sample doesn't require asynchronous Web Service access, so that this option can be switched off. The last screen summarizes the methods exposed by the Web Services, which also become available on the JAX-WS proxy. 4

Using a Java Bean wrapper class as the Data Control The Web Services client can be tested using the Client class which has a main method defined. In the sample, the client class is AllEmployeesBeanServiceClient. To access a Web Service client proxy from Oracle ADF, best practice is to do this through a POJO bean access in the proxy class, so the Oracle ADF data control access is decoupled from the implementation of the proxy class. This allows re-generating the Web Service proxy without impacting the Oracle ADF data control access. In the example, this POJO is AllEmployeesServiceWrapperBean.java. The POJO accesses the client proxy and exposes the methods to query the Web Services. Within the POJO, the returned data from the Web Service are cached for later use. In the following, whenever the table data is queried, the Java code first check if the data already exists in the cache and if, it takes it from there. 5

import adf.sample.model.jpa.allemployeesbean; import adf.sample.model.jpa.allemployeesbeanservice; import adf.sample.model.jpa.employees; import java.util.arraylist; import java.util.list; /** * Java Bean that is exposed as a data control. The bean accesses the * JAX-WS proxy client to expose methods of the Web Service */ public class AllEmployeesServiceWrapperBean { //Web Service proxy client class AllEmployeesBean allemployeesbean = null; AllEmployeesBeanService allemployeesbeanservice = null; //List object for caching List<Employees> employeescache = null; List<Employees> employeesret = null; final int VALUE_MATCH = 0; public AllEmployeesServiceWrapperBean() { super(); //connect to the proxy client allemployeesbeanservice = new AllEmployeesBeanService(); allemployeesbean = allemployeesbeanservice.getallemployeesbeanservice(); //query all employees. This method is called when the ADF table //executes its underlying iterator public List<Employees> getallemployees(){ if(employeescache == null){ employeescache = allemployeesbean.getemployeesfindall(); employeesret = employeescache; else if(employeesret == null){ employeesret = employeescache; return employeesret; //To some point, you may want to re-execute the service to get the //latest data. //In this case, the cache List is set to null. 6

public void clearproxycache(){ employeescache = null; //to filter the data displayed in the table, an extra method is //exposed on the POJO and thus the Data Control. Instead of querying //the Web Service, this method operates on the cached data public void filteremployeesbydepartmentid(long departmentid){ employeesret = new ArrayList<Employees>(); if(departmentid == null){ employeesret = employeescache; return; for(employees emp : employeescache){ if(emp.getdepartmentid()!= null && emp.getdepartmentid().compareto(departmentid)== VALUE_MATCH){ employeesret.add(emp); The AllEmployeesServiceWrapperBean is the turned into a Data Control to expose its methods and thus the functionality exposed on the Web Service to Oracle ADF. For this, select the AllEmployeesServiceWrapperBean file in the Oracle JDeveloper Application Navigator and choose Create Data Control from the context menu as shown in the image below. 7

The methods, collections and attributes exposed in the AllEmployeesServiceWrapperBean bean now show in the Data Control panel from where they can be dragged into an ADF Faces page. Note: To further customize a collection like allemployees, for example to define UI hints to the attributes it exposes, select the collection in the Data Controls panel and use the right mouse button to display the Edit Definition menu option. Display WS data in an ADF Faces table and enable In the sample, to create a table from a collection, the allemployees collection is dragged from the Data Controls panel and dropped onto the ADF Faces page. In the component context menu that opens, the read only table option was chosen. In the table edit dialog, the filter option was selected to show search fields in the column headers. When users type a search string in, and hit Enter the table re-executes the query to apply the filter condition. Because the query is passed on to the wrapper bean and not directly to the Web Service, the filtered data is read from the in-memory cache. 8

Similar, to create a search field that also filters the data displayed in the table using in memory implemented in the wrapper bean, the filteremployeesbydepartmentid method was dragged from the Data Controls panel and dropped as a parameter form. The command button was renamed to "Filter". To clear the in-memory cache so that the next query again queries data from the Web Service directly, the clearproxycache method was dragged as a command button to the panel form. The Refresh condition of the iterators in the PageDef file was set to ifneeded to refresh the data content when preparing the ADF data model. The sample references the following managed bean codes in the command buttons action property. The managed beans ensure the ADF iterator is re-executed when the data was changed in the bean wrapper exposed by the Data Control ------------------------------------ Filter Query Bean ------------------------------------ import oracle.adf.model.bindingcontext; import oracle.adf.model.binding.dciteratorbinding; import oracle.adf.view.rich.component.rich.data.richtable; import oracle.binding.bindingcontainer; import oracle.binding.operationbinding; public class FilterQueryBean { public FilterQueryBean() { public BindingContainer getbindings() { return BindingContext.getCurrent().getCurrentBindingsEntry(); public String cb1_action() { BindingContainer bindings = getbindings(); OperationBinding operationbinding = bindings.getoperationbinding("filteremployeesbydepartmentid"); Object result = operationbinding.execute(); if (!operationbinding.geterrors().isempty()) return null; 9

//re-execute iterator to get data from the wrapper bean DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("allemployeesiterator1"); dciter.executequery(); return null; ------------------------------------ Reset Query Bean ------------------------------------ import oracle.adf.model.bindingcontext; import oracle.adf.model.binding.dciteratorbinding; import oracle.binding.bindingcontainer; import oracle.binding.operationbinding; public class ResetQuerybean { public ResetQuerybean() { public BindingContainer getbindings() { return BindingContext.getCurrent().getCurrentBindingsEntry(); public String cb2_action() { BindingContainer bindings = getbindings(); OperationBinding operationbinding = bindings.getoperationbinding("clearproxycache"); Object result = operationbinding.execute(); if (!operationbinding.geterrors().isempty()) { return null; DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("allemployeesiterator1"); dciter.executequery(); return null; Sample download You can download the Oracle JDeveloper 11g R1 workspace as sample 92 from the ADF Code Corner Website: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#codecornersamples Configure the database access for this demo to point to the HR sample schema of an Oracle XE or enterprise database. Run the JSPX document and either filter the table data using the column header filters or the search field. To reset the query, press the ClearPrxyCache command button. 10

RELATED DOCOMENTATION 11