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



Similar documents
ADF Code Corner. 92. Caching ADF Web Service results for in-memory filtering. 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 How-to pass values from a parent page to a popup dialog. Abstract: twitter.com/adfcodecorner

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

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. 81. How-to create master-detail behavior using af:paneltabbed and DVT graph components. Abstract: twitter.

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

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

Task Flow Design Fundamentals

An Oracle White Paper October Frequently Asked Questions for Oracle Forms 11g

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

ADF Code Corner. Oracle JDeveloper OTN Harvest 08 / Abstract: twitter.com/adfcodecorner

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

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

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

Developing Rich Web Applications with Oracle ADF and Oracle WebCenter Portal

Vodafone PC SMS (Software version 4.7.1) User Manual

ORACLE ADF MOBILE DATA SHEET

SBBWU PROXY SETTING IT CENTRE How to Set a Proxy Server in All Major Internet Browsers for Windows

An Overview of Oracle Forms Server Architecture. An Oracle Technical White Paper April 2000

JMS 2.0: Support for Multi-tenancy

Build a Mobile App in 60 Minutes with MAF

Introduction to Ingeniux Forms Builder. 90 minute Course CMSFB-V6 P

Open Directory. Contents. Before You Start 2. Configuring Rumpus 3. Testing Accessible Directory Service Access 4. Specifying Home Folders 4

NODE4 SERVICE DESK SYSTEM

SPAMfighter Mail Gateway

Outlook Plugin. What is MangoApps for Outlook?

SAP CRM 7.0 E2C Setup: CRM via Toolset

LAE 5.1. Windows Server Installation Guide. Version 1.0

1. SQL Search 1 documentation Requirements Installing Upgrading Using SQL Search Troubleshooting...

Vizit 4.1 Installation Guide

Release Notes for SOA Suite 11g Technology Preview 4

Salesforce Classic Guide for iphone

Notes on how to migrate wikis from SharePoint 2007 to SharePoint 2010

VPS Hosting User Guide

...2. Standard Installation...4. Example Installation Scenarios...5. Network Installation...8. Advanced Settings Product Requirements

Sample- for evaluation purposes only. Advanced Crystal Reports. TeachUcomp, Inc.

Guide to Setup using Microsoft Outlook Express

Java and JavaScript. Krishna Tateneni

Building Web Services with Apache Axis2

ORACLE MOBILE APPLICATION FRAMEWORK DATA SHEET

User guide. Business

NAS 103 Wake-on-LAN (WOL) Set up and use WOL with your ASUSTOR NAS

Oracle Hyperion Financial Management Developer and Customization Guide

Oracle Hyperion Financial Management Custom Pages Development Guide

Instant Chime for IBM Sametime Installation Guide for Apache Tomcat and Microsoft SQL

Oracle Application Development Framework Overview

Practice Fusion API Client Installation Guide for Windows

GE Intelligent Platforms. Activating Licenses Online Using a Local License Server

T320 E-business technologies: foundations and practice

IMRG Peermap API Documentation V 5.0

Data Warehouse Troubleshooting Tips

Migrating an Oracle Forms application from 6i to 10g- Technical considerations


How do I load balance FTP on NetScaler?

Oracle Forms Services Secure Web.Show_Document() calls to Oracle Reports

Date: 22/10/12 Version: 3.2

Accounts Production Installation Guide

Getting Started Guide. Version 1.8

Guide to the Laserfiche Support Site. White Paper

Performance Testing for Ajax Applications

DRIVE-BY DOWNLOAD WHAT IS DRIVE-BY DOWNLOAD? A Typical Attack Scenario

Shentel (Shentel.net)

Building and Using Web Services With JDeveloper 11g

Install/Upgrade Instructions for using CompuLaw with Amicus Attorney 2010 Premium Edition

Creating an Ad hoc Network in Windows XP

This walk-through was created using Windows XP as a guide, however alternate versions of the Windows OS will be very similar in procedure as well.

>

Witango Application Server 6. Installation Guide for Windows

ORACLE WEBCENTER PORTAL

The Answer to the 14 Most Frequently Asked Modbus Questions

Activation of your SeKA account

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

Accelerated Java EE Open Source Development with Eclipse CON1905

Excel Templates. & Quote/Invoice Maker for ACT! Another efficient and affordable ACT! Add-On by V

IMAP and SMTP Setup in Clients

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

Best Practices for... "Setting up notifications for alerts"

MS SQL Express installation and usage with PHMI projects

Configuring iplanet 6.0 Web Server For SSL and non-ssl Redirect

<Insert Picture Here> Web 2.0 Data Visualization with JSF. Juan Camilo Ruiz Senior Product Manager Oracle Development Tools

Installing Oracle 12c Enterprise on Windows 7 64-Bit

All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information.

Expense Management. Configuration and Use of the Expense Management Module of Xpert.NET

Below shows the examples of FAX application through PSTN Trunk and SIP Trunk with VigorIPPBX 3510.

NN Markedsdata application installation instruction

LRGS Client Getting Started Guide

Logging into the control panel

Canaveral iq WBT Add-on for Windows CE 2.12-based Wyse Terminals

Oracle SOA Suite 11g Oracle SOA Suite 11g HL7 Inbound Example

IPRO Viewer. Installation

An introduction to creating JSF applications in Rational Application Developer Version 8.0

EventSentry Overview. Part I Introduction 1 Part II Setting up SQL 2008 R2 Express 2. Part III Setting up IIS 9. Part IV Installing EventSentry 11

OFF-LINE COMMUNICATIONS WITH CINCINNATI EQUIPMENT Pg. 1 of 5

Step-by-Step Setup Guide Wireless File Transmitter FTP Mode

Transcription:

ADF Code Corner 011. ADF Faces RC - How-to use the Client and Server Abstract: One of the most interesting features in Ajax is the ability of an application to send user information to the server without user recognition. A positive use of this feature is the auto suggest feature, which provides the user with a list of possible select values based on the user input into a text field. Another positive use is auto completion of strings, in which case the user enters a shortcut into a text field e.g. "NY" for the system to complete the field with New York. This how-to document shows how this Ajax functionality is achieved in ADF Faces RC using the client and server listener component. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 14-JUN-2008

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 this how-to example, we explore a negative use of the Ajax asynchronous messaging functionality, which is the ability of an application to spy on the user input. Before you can shout "security breach", let me reassure that this application doesn't cause any harm. I just chose this example because its cool. The sample code, as usual, can be downloaded at the end of this how-to document. The sample application consist of two text fields that each intercepts the user input to send it to the server as the user types. The difference between the fields is that the first field has the functionality configured at designtime, whereas the second has it configured dynamically through a managed bean. The latter thus allows you to provide this functionality dynamically: your application may contain a checkbox that if checked provides text auto completion as otherwise it wont. As soon as the user types into one of the fields, the characters are send to the server where they can be accessed from a managed bean method. Configuring a clientlistener and serverlistener at designtime At designtime you use the following artifacts to configure asynchronous messages to be send to the server af:clientlistener af:serverlisterner JavaScript method called by the client listener <af:document> <f:facet name="metacontainer"> 2

<af:group> <![CDATA[ <script> function clientmethodcall(event) { component = event.getsource(); AdfCustomEvent.queue(component, "customevent", {payload:component.getsubmittedvalue(), true); event.cancel(); </script> ]]> </af:group> </f:facet> <af:form> <af:panelformlayout> <f:facet name="footer"/> <af:inputtext label="let me spy on you: Please enter your mail password"> <af:clientlistener method="clientmethodcall" type="keyup"/> <af:serverlistener type="customevent" method="#{custombean.handlerequest"/> </af:inputtext>... The af:clientlistener calls the JavaScript method on the page whenever the keyup JavaScript event occurs on the text field. The JavaScript function then gets a hold onto the event source, the text field, to read its submitted text value. The text then is passed to the server listener, which listens under the name of "customevent". The bean method, which is mapped by the serverlistener component, is custombean.handlerequest: public void handlerequest(clientevent event){ System.out.println("---"+event.getParameters().get("payload")); 3

The managed bean can be configured either in the faces-config.xml file or the adfc-config.xml file, which is the Oracle taskflow configuration. All that the method does in the above example is to print out the user entered values. However, as you see you can access the payload by requesting it as a parameter on the event object passed into the method. Note that the term "payload" is arbitrarily chosen by me. You are free to choose whatever name pleases you. Configuring a clientlistener and serverlistener at runtime To apply a client and server listener dynamically, an additional step is required, which is to create a binding reference of the text field to the managed bean that adds the listeners to it. <af:inputtext label="i am a spy too!" binding="#{custombean.secondspyfield"/> As you can see. the definition of the text field doesn't contain the clientlistener and serverlistener elements, but instead has the binding property set to the managed bean. To add the client and server listener on page load, the following code in the managed bean is required public void setsecondspyfield(richinputtext secondspyfield) { this.secondspyfield = secondspyfield; if (this.secondspyfield!=null){ ClientListenerSet cls = new ClientListenerSet(); cls.addlistener("keyup","clientmethodcall"); cls.addcustomserverlistener( "customevent", getmethodexpression("#{custombean.handlerequest")); this.secondspyfield.setclientlisteners(cls); 4

public RichInputText getsecondspyfield() { return secondspyfield; public MethodExpression getmethodexpression(string s){ FacesContext fc = FacesContext.getCurrentInstance(); ELContext elctx = fc.getelcontext(); ExpressionFactory elfactory = fc.getapplication().getexpressionfactory(); MethodExpression methodexpr = elfactory.createmethodexpression(elctx,s,null,new Class[]{ClientEvent.class); return methodexpr; Within the setter of the text field binding, the two listeners are added. The JavaScript function that handles the client method call is assumed to be on the page. There are ways to dynamically add JavaScript to a page using the extended renderkit service, but for this example we assume the JavaScript function to exist. The key for making the dynamic approach work is within the getmethodexpression function. When building the method expression you need to tell the method's input arguments, which in the case of the server listener is of type ClientEvent. Download You can download the sample explained in this article from the ADF Code Corner site: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html RELATED DOCOMENTATION af:clientlistener - http://download.oracle.com/docs/cd/e15523_01/apirefs.1111/e12419/tagdoc/af_clientlistener.html af:serverlistener - http://download.oracle.com/docs/cd/e15523_01/apirefs.1111/e12419/tagdoc/af_serverlistener.html 5