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



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

ADF Code Corner. 92. Caching ADF Web Service results for in-memory filtering. 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 ADF Faces RC - How-to use the Client and Server Listener Component. Abstract: twitter.com/adfcodecorner

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

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

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

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

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

Developing Rich Web Applications with Oracle ADF and Oracle WebCenter Portal

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

Oracle Hyperion Financial Management Custom Pages Development Guide

Oracle Hyperion Financial Management Developer and Customization Guide

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

The Oracle Fusion Development Platform

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

Oracle Application Development Framework Overview

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

Building and Using Web Services With JDeveloper 11g

Task Flow Design Fundamentals

Eclipse installation, configuration and operation

A Developers Journey From Oracle EBS Forms To Oracle EBS ADF Pages

Before you may use any database in Limnor, you need to create a database connection for it. Select Project menu, select Databases:

Oracle JDeveloper 10g for Forms & PL/SQL

How to Use the Billericay School Portal

Smooks Dev Tools Reference Guide. Version: GA

Installing Java 5.0 and Eclipse on Mac OS X

Business Objects. Report Writing - CMS Net and CCS Claims

Enterprise Service Bus

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

How to install and use the File Sharing Outlook Plugin

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

ABAP Debugging Tips and Tricks

ORACLE ADF MOBILE DATA SHEET

CafePilot has 3 components: the Client, Server and Service Request Monitor (or SRM for short).

Amplify Service Integration Developer Productivity with Oracle SOA Suite 12c

From Forms to ADF When, Why and How? Senior Group Product Manager - Application Development Tools

How to share media files through Windows Media Player 11

Installing Oracle 12c Enterprise on Windows 7 64-Bit

Data Crow Creating Reports

NetBeans and GlassFish v 2.1 Creating a Healthcare Facility Visual Web Application

Chapter 14: Links. Types of Links. 1 Chapter 14: Links

Tutorial: Building a Web Application with Struts

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

Developing Web and Mobile Dashboards with Oracle ADF

MiraCosta College now offers two ways to access your student virtual desktop.

Android Mobile App Building Tutorial

Developing SQL and PL/SQL with JDeveloper

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

Installing the Android SDK

Download and Installation Instructions. Java JDK Software for Windows

Struts Tools Tutorial. Version: M5

ADF. Joe Huang Joe Huang Senior Principal Product Manager, Mobile Development Platform, Oracle Application Development Tools

Microsoft Access 3: Understanding and Creating Queries

Software Licensing Management North Carolina State University software.ncsu.edu

Cleaning your Windows 7, Windows XP and Macintosh OSX Computers

Publishing, Consuming, Deploying and Testing Web Services

Creating a Network Graph with Gephi

Abstract. For notes detailing the changes in each release, see the MySQL for Excel Release Notes. For legal information, see the Legal Notices.

Tutorial: BlackBerry Object API Application Development. Sybase Unwired Platform 2.2 SP04

Mitigation Planning Portal MPP Reporting System

Creating Carbon Menus. (Legacy)

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

TIBCO ActiveMatrix BPM - Integration with Content Management Systems

TSM Studio Server User Guide

Finding Information about your Purchase Orders (POs) and Requisitions

ORACLE MOBILE APPLICATION FRAMEWORK DATA SHEET

CONTACTS SYNCHRONIZER FOR IPAD USER GUIDE

ODBC Client Driver Help Kepware, Inc.

Cal Answers Analysis Training Part III. Advanced OBIEE - Dashboard Reports

Building Java Servlets with Oracle JDeveloper

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

NEW IR DATA WAREHOUSE

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

Don t get it right, just get it written.

Java version 7 update 45 (7u45)

Customer Portal User Manual Scott Logic Limited. All rights reserve Scott Logic Limited. All rights reserved

Enterprise Remote Control 5.6 Manual

Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3 SP02

SEER Enterprise Shared Database Administrator s Guide

Contents. Introduction. Chapter 1 Some Hot Tips to Get You Started. Chapter 2 Tips on Working with Strings and Arrays..

<Insert Picture Here> Michael Hichwa VP Database Development Tools Stuttgart September 18, 2007 Hamburg September 20, 2007

Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3

Hypercosm. Studio.

Title: SharePoint Advanced Training

PubMatic Android SDK. Developer Guide. For Android SDK Version 4.3.5

Generate Android App

Table of Contents. Introduction: 2. Settings: 6. Archive 9. Search Browse Schedule Archiving: 18

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

Change Management for Rational DOORS User s Guide

WA2102 Web Application Programming with Java EE 6 - WebSphere RAD 8.5. Classroom Setup Guide. Web Age Solutions Inc. Web Age Solutions Inc.

Voyager Reporting System (VRS) Installation Guide. Revised 5/09/06

BPEL + Business Rules

Transcription:

ADF Code Corner 046. Building a search form that displays the results in a task Abstract: One of the areas that really rocks in JDeveloper 11 is tasks. To program usecases that involve tasks can keep you busy for weeks if the goal is to provide a library of code examples. The use case explained in this blog post is quite simple and is based on frequent requests posted on the Oracle JDeveloper forum on OTN twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 03-Apr-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 A JSF page has a textfiled and a search button. The user enters a department number and hits the "search" button. The result of this search, which uses ExecuteWithParams in ADF Business Components, shows in a popup dialog on the same page. To enforce reuse - one of the big themes in JDeveloper 11 - the popup content is a task that shows in a region. The challenges solved in this usecase are: 1) The input argument is of type String - as everything on the web starts as a string before it gets converted - whereas the bind variable used within the ExecuteWithParams operation is of type oracle.jbo.domain.number. Because of this, the result oage cannot be called directly and instead a method needs to be called first to prepare the model before the result page is called 2) The search string needs to be passed to the region as an input parameter. Further, the region needs to be updated whenever a new parameter is passed. 2

3) The popup needs to be closed programmatically. This part is easy and I am reusing the code from another blog entry of mine At runtime, the application works as shown below A tiny bit that I haven't yet got working using the af:showpopupbehavior, which works if launching the popup using the af:clientlistener with JavaScript, is to proper adjust the position of the popup. However, JDeveloper 11 is not production yet, so no need to worry too much about this yet. Pressing the close button on the popup will dismiss the popup window. Pressing the search button again will re-open it with the query result of the new search input. How-to The query is performed within the method activity, which is the default activity in the task and that routes the request to the page fragment that displays the result table once finished. public void executequery(){ FacesContext fctx = FacesContext.getCurrentInstance(); ELContext elctx = fctx.getelcontext(); Application jsfapp = fctx.getapplication(); ExpressionFactory exprfct = jsfapp.getexpressionfactory(); ValueExpression adfdatavexpr = exprfct.createvalueexpression(elctx, "#{data}",bindingcontext.class); BindingContext adfdata = (BindingContext) adfdatavexpr.getvalue(elctx); ValueExpression deptiddatavexpr = exprfct.createvalueexpression(elctx, "#{pageflowscope.deptidtaskflowparam}",object.class); if (deptiddatavexpr.getvalue(elctx)!= null){ 3

String deptidstr = (String) deptiddatavexpr.getvalue(elctx); try { Integer deptidint = Integer.parseInt(deptIdStr); BindingContainer bindings = adfdata.findbindingcontainer("browseemployeespagedef"); bindings.getoperationbinding( "ExecuteWithParams").getParamsMap().put("deptId", new Number(deptIdInt.intValue())); bindings.getoperationbinding("executewithparams").execute(); } catch (NumberFormatException ex) { ex.printstacktrace(); } } return; } The initial code lines are there to get a hold of the ExecuteWithParams method that is contained in the pagedef file associated with the page fragment. Theinteresting bits start with line 10. In here, the parameter that is passed from the calling page to the region (task) is accessed and then converted to oracle.jbo.domain.number before it is used to execute the ExecuteWithParams operation. When you drag a task as a region onto a page, then - if the task requires an input parameter, the pagedef file of the page on which the region is added, is updated with the region definition and input parameter binding In the image above, you see that the input parameter that is defined on the task, reads its value from #{pageflowscope.deptidsearch}, an attribute added to the pageflowscope of the calling page. The attribute is updated by the search field on the page <af:inputtext label="search Condition (in Number)" id="searchfield1" value="#{pageflowscope.deptidsearch}"/> So anything that the user types into the search field, gets written to the pageflowscope attribute when pressing the search button, which performs the form submit. Important to note is that if you want to launch a popup dialog from a button, you must ensure that the button uses a partial submit instead of performing a full page refresh 4

<af:commandbutton text="search" id="searchbutton" partialsubmit="true"> <af:showpopupbehavior popupid="browseemployeespopup" triggertype="click"/> </af:commandbutton> So what do we have until here, and what is missing still? We have a task that starts with a method call to prepare the query for the table. The method takes an input argument that is passed to the task from the region. The region accesses the parameter value from an attribute in the pageflowscope of the calling page. The remaining job is to make sure the task input parameter writes the input parameter to its own pageflowscope so the Java method can access it using EL. adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2"> <task--definition id="browseemployees--definition"> <default-activity>executeemployeesquery</default-activity> <input-parameter-definition> <name>deptidtaskflowparam</name> <value>#{pageflowscope.deptidtaskflowparam}</value> <required/> </input-parameter-definition> <managed-bean> <managed-bean-name>employeesbean</managed-bean-name> <managed-bean-class>adf.sample.employeesbean</managed-bean-class> <managed-bean-scope>pageflow</managed-bean-scope> </managed-bean> <view id="browseemployees"> <page>/browseemployees.jsff</page> </view> <method-call id="executeemployeesquery"> <method>#{pageflowscope.employeesbean.executequery}</method> <outcome> <fixed-outcome>showemployees</fixed-outcome> </outcome> </method-call> <control--rule> <from-activity-id>executeemployeesquery</from-activity-id> <control--case> <from-outcome>showemployees</from-outcome> <to-activity-id>browseemployees</to-activity-id> </control--case> </control--rule> <use-page-fragments/> </task--definition> </adfc-config> The task source shows the following The default activity - and thus the first action performed when entering the task - is the method call to a managed bean. <default-activity>executeemployeesquery</default-activity> The input parameter is defined as "deptidtaskflowparam", which is the same name used in the region binding, and writes the obtained value to #{pageflowscope.deptidtaskflowparam} from where it is accessed by the managed bean method 5

<input-parameter-definition> <name>deptidtaskflowparam</name> <value>#{pageflowscope.deptidtaskflowparam}</value> <required/> </input-parameter-definition> The remaining information to give is that I set the "Refresh" property on the region binding in the pagedef file of the calling page to "ifneeded", which makes sure that the region binding is updated whenever the input parameter changes. Download You can download the workspace with the sample - based on the HR schema from ADF Code Corner http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html RELATED DOCOMENTATION 6