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



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. 92. Caching ADF Web Service results for in-memory filtering. 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 Building a search form that displays the results in a task flow. Abstract: twitter.com/adfcodecorner

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

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

Developing Rich Web Applications with Oracle ADF and Oracle WebCenter Portal

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

Developing Web and Mobile Dashboards with Oracle ADF

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

Building and Using Web Services With JDeveloper 11g

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

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

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

ORACLE BUSINESS INTELLIGENCE WORKSHOP

Foglight. Dashboard Support Guide

Oracle Business Intelligence ADF Custom Visualizations and Integration. An Oracle White Paper November 2012

How to Create User-Defined Fields and Tables

Oracle Application Development Framework Overview

SQL Server 2005: Report Builder

How to Login Username Password:

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

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Working with SQL Server Integration Services

Configuring the SST DeviceNet OPC Server

ICP Data Validation and Aggregation Module Training document. HHC Data Validation and Aggregation Module Training Document

Designing portal site structure and page layout using IBM Rational Application Developer V7 Part of a series on portal and portlet development

Business Process Management IBM Business Process Manager V7.5

An Oracle White Paper September Oracle Team Productivity Center

Terms and Definitions for CMS Administrators, Architects, and Developers

Saving work in the CMS Edit an existing page Create a new page Create a side bar section... 4

Activities Manual. Product Manual. Table of Contents. 1. efolio Overview Benefits

LabVIEW Report Generation Toolkit for Microsoft Office User Guide

How to Add Social Media Icons to Your Website

Scribe Online Integration Services (IS) Tutorial

Business Objects Version 5 : Introduction

Application. 1.1 About This Tutorial Tutorial Requirements Provided Files

The Oracle Fusion Development Platform

Task Flow Design Fundamentals

Tutorial: Mobile Business Object Development. SAP Mobile Platform 2.3

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

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

Microsoft Office Excel 2013

Generating Open For Business Reports with the BIRT RCP Designer

Spotfire v6 New Features. TIBCO Spotfire Delta Training Jumpstart

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

Oracle JDeveloper 10g for Forms & PL/SQL

BLUECIELO MERIDIAN ASSET MANAGEMENT MODULE 2014

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

Quick start. A project with SpagoBI 3.x

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

Table of Contents. Manual for Core Staff - Equipment/Scheduling Core Facilities

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

Gephi Tutorial Quick Start

Google Sites: Site Creation and Home Page Design

Stored Documents and the FileCabinet

IBM Information Server

Using Flow Control with the HEAD Recorder

Education Solutions Development, Inc. APECS Navigation: Business Systems Getting Started Reference Guide

Creating Database Model Diagrams in Microsoft Visio Jeffery S. Horsburgh

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

Esigate Module Documentation

Excel Using Pivot Tables

OBIEE 11g : Answers, Dashboards & More

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

Microsoft Excel 2007 Level 2

Business Objects 4.1 Quick User Guide

edgebooks Quick Start Guide 4

RemoteWare Software Manager

EditAble CRM Grid. For Microsoft Dynamics CRM. How To Guide. Trial Configuration: Opportunity View EditAble CRM Grid Scenario

Visual Studio.NET Database Projects

Application Developer Guide

DbSchema Tutorial with Introduction in SQL Databases

Database Forms and Reports Tutorial

Jadu Content Management Systems Web Publishing Guide. Table of Contents (click on chapter titles to navigate to a specific chapter)

ONBASE OUTLOOK CLIENT GUIDE for 2010 and 2013

WHAT S NEW IN OBIEE

Knowledgebase Article

Transaction Monitoring Version for AIX, Linux, and Windows. Reference IBM

Downloading RIT Account Analysis Reports into Excel

Intelligent Event Processer (IEP) Tutorial Detection of Insider Stock Trading

1. Right click using your mouse on the desktop and select New Shortcut.

Publishing Geoprocessing Services Tutorial

HOW TO ORGANIZE PICTURES

Getting Started Using AudibleManager. AudibleManager 5.0

Toad for Data Analysts, Tips n Tricks

Introduction To Microsoft Office PowerPoint Bob Booth July 2008 AP-PPT5

Introduction to IBM Digital Analytics Michigan.gov

Recruiting Hiring Managers. Guide for Users Updated on 28 June 2016

Creating a Table of Contents in Microsoft Word 2011

In This Issue: Excel Sorting with Text and Numbers

Active Directory Integration for Greentree

Transcription:

ADF Code Corner 81. s Abstract: Oracle ADF Faces tree, tree table and table components keep track of their row (node) selection state, allowing developers to access the selected data rows, for example, to fetch dependent detail data or similar operations. The af:iterator component behaves like trees or table in that it stamps it child components, but does not keep track of the selected data row. This sample shows how you can build better user interfaces for master-detail data display using the af:iterator component while still keeping track of the current row selection. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 01-MAY-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 The af:iterator component and the af:foreach component both iterate over a data set to display data values in custom arranged user interfaces. The af:iterator component behaves like an ADF Faces table component, without the table header, column, row and border chrome. It works well with collection models, which are exposed by the ADF tree binding in the PageDef file. In general, using af:iterator is a lower footprint on the client than using af:foreach. The af:foreach tag substiutes the JSTL c:foreach tag, which does not support the "varstatus" reference that give developers access to the iteration statelike. the index of the current printed row. The af:foreach component does not stamp it children but creates object representations and renders list data. It does not support collections. As af:foreach is index based, items should not be removed after the list is rendered. A use case for this component is to dynamically render entries of an af:selectonechoice list. In this article, I explain how you use the af:iterator to iterate over a master detail set to render its rows as tabs in an af:paneltabbed component. Each tab contains an ADF bound graph that displays dependent detail data. 2

The ADF BC model The ADF Business Components model is a master-detail structure consisting of a DepartmentsView view object and an EmployeesView view object. The data model defined in the ADF BC Application Module exposes an instance of departments and employees that is connected by a ViewLink so that selecting a department automatically synchronizes the dependent employee detail records. For demonstration purposed only, the alldepartments instance is filtered by a ViewCriteria to only show departments having employees. The image below shows the data model in the Data Controls panel view. ADF Faces implementation To implement the solution, you create an ADF tree binding in the PageDef file of the view that should contain the master-detail display. To create an ADF tree binding, right mouse click onto the page or page fragment and choose Go to Page Definition. If no ADF binding file exists, it can be created on the fly. With the binding file open, click the green plus icon in the Bindings section 3

From the list of ADF bindings, choose the tree binding Use the Add button in the Create Tree Binding dialog to create a new iterator to base the tree binding on. In the image below, the iterator is created for the alldepartmentswithemployees View Object instance. Create rules for the tree nodes, like you are familiar with when building trees from dragging a collection from the Data Control panel. 4

Drag and drop the af:paneltabbed component from the ADF Faces component palette onto the view. This automatically adds a default Show Detail Item to represent a tab. Next, surround the af:showdetailitem component with an af:iterator tag, using the source editor. Of course, there is a declarative and visual way of doing the same, but over time I found the use of the source editor for this to be quick and efficient, especially because of the tag and syntax help Oracle JDeveloper provides. <af:paneltabbed id="pt1"> 5

<af:iterator var="deptrow" value="#{bindings.alldepartmentswithemployees.collectionmodel"> <af:showdetailitem text="#{deptrow.departmentname" id="sdi1" disclosurelistener="#{graphbean.ontabdisclosure"> <f:attribute name="rowkey" value="#{deptrow.keypath"/> </af:showdetailitem> </af:iterator> </af:paneltabbed> Note the content highlighted in bold! The var attribute defines an EL accessible object during rendering, which gives you access to the current rendered data row. This variable is used in an f:attribute tag, which is the JSF way of extending existing components with additional attributes. In the use case above, the key path of the current row is added as a new "rowkey" attribute to the af:showdetail component. The rowkey value is different for each tab generated for a department. Also note the reference of the ADF tree binding (alldepartmentswithemployees.collectionmodel) from the value attribute of the af:iterator tag. A disclosure listener is defined on the af:dowdetailitem component to handle the master-detail correlation. Handling the master-detail correlation in this use case means to access the selected detail item, read the key path value from the rowkey attribute and make this key the current selected row in the alldepartmentswithemployees iterator. The managed bean containing the disclosure listener, is shown below public class GraphBean { //bean is in request scope. So accessing FacesContext here is //okay as there is no risk of using stale context data FacesContext fctx = FacesContext.getCurrentInstance(); ELContext elctx = fctx.getelcontext(); ExpressionFactory expressionfactory = fctx.getapplication().getexpressionfactory(); public GraphBean() { super(); //called by each tab with a changed disclosure state public void ontabdisclosure(disclosureevent disclosureevent) { RichShowDetailItem tab = (RichShowDetailItem) disclosureevent.getsource(); if (tab.isdisclosed()) { //read the custom attribute "rowkey" from the showdetailitem //component reference. Note that the key is the key of the data //in the collection model and thus is a List 6

List key = (List)tab.getAttributes().get("rowKey"); JUCtrlHierBinding treebinding = this.gettreebinding(); //get the ADF tree binding node that corresponds with the //key path in the Collection Model JUCtrlHierNodeBinding currentnode = treebinding.findnodebykeypath(key); //make the current node the current row in ADF makecurrent(currentnode); /* * Make row current in underlying iterator */ private void makecurrent(juctrlhiernodebinding node){ //get the key of the row represented //by the node binding Row rw = node.getrow(); Key key = rw.getkey(); //make this row the current row in the binding layer //so master/detail behavior works correctly JUCtrlHierBinding treebinding = this.gettreebinding(); DCIteratorBinding iterator = treebinding.getdciteratorbinding(); iterator.setcurrentrowwithkey(key.tostringformat(true)); private JUCtrlHierBinding gettreebinding(){ BindingContext bctx = BindingContext.getCurrent(); BindingContainer bindings = bctx.getcurrentbindingsentry(); //get reference to tree binding by its ID in the PageDef JUCtrlHierBinding treebinding = (JUCtrlHierBinding) bindings.get("alldepartmentswithemployees"); return treebinding; Making the selected tab's keypath value the current row in ADF, synchronizes the employees data to show employees for the selected department. If the business service was not ADF Business Components but Web Services, you would take the key path value, or a primary key value, and call a method exposed on the service. Only change to this sample is that the Refresh attribute on the iterators should be set to ifneeded instead of deferred, which is used in this sample. To display the Graph, you select the EmployeesInDepartment collection from the DataControls panel and drag and drop it into the showdetailitems component. 7

The completed page source then looks as shown below <af:paneltabbed id="pt1"> <af:iterator var="deptrow" value="#{bindings.alldepartmentswithemployees.collectionmodel"> <af:showdetailitem text="#{deptrow.departmentname" id="sdi1" disclosurelistener="#{graphbean.ontabdisclosure"> <f:attribute name="rowkey" value="#{deptrow.keypath"/> <dvt:bargraph id="bargraph1" value="#{bindings.employeesindepartment.graphmodel" subtype="bar_vert_clust"> <dvt:background> <dvt:specialeffects/> </dvt:background> <dvt:graphplotarea/> <dvt:seriesset> <dvt:series/> </dvt:seriesset> <dvt:o1axis/> <dvt:y1axis/> <dvt:legendarea automaticplacement="ap_never"/> </dvt:bargraph> </af:showdetailitem> 8

</af:iterator> </af:paneltabbed> Download The Oracle JDeveloper 11.1.1.4 workspace can be downloaded as sample #81 from the ADF Code Corner website. http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html Configure the database connection in the workspace to point to a database with the HR schema installed and run the JSPX file. The steps explained in this sample should also work with upcoming JDeveloper 11g releases (11.1.1.5 and 11.1.2), as well as with previous 11g versions. RELATED DOCOMENTATION ADF Faces af:iterator tag documentation: http://download.oracle.com/docs/cd/e17904_01/apirefs.1111/e12419/tagdoc/af_iterator.html ADF Faces af:foreach tag documentation http://download.oracle.com/docs/cd/e17904_01/apirefs.1111/e12419/tagdoc/af_foreach.html 9