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



Similar documents
ADF Code Corner How-to drag-and-drop data from an af:table to af:tree. 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. 92. Caching ADF Web Service results for in-memory filtering. Abstract: twitter.com/adfcodecorner

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

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 Building a search form that displays the results in a task flow. Abstract: twitter.com/adfcodecorner

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

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

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

Forum of International Development Studies 21 (Mar. 2002)

Task Flow Design Fundamentals

Developing Rich Web Applications with Oracle ADF and Oracle WebCenter Portal

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

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

Oracle JDeveloper 10g for Forms & PL/SQL

ORACLE BUSINESS INTELLIGENCE WORKSHOP

Tutorial: Building a Web Application with Struts

Foglight. Dashboard Support Guide

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

Oracle Hyperion Financial Management Custom Pages Development Guide

The Oracle Fusion Development Platform

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

Oracle Application Development Framework Overview

SUMMARY. e-soft s.r.l.

SQL Simple Queries. Chapter 3.1 V3.0. Napier University Dr Gordon Russell

Oracle Business Intelligence Server Administration Guide. Version December 2006

Building and Using Web Services With JDeveloper 11g

An Oracle White Paper June Creating an Oracle BI Presentation Layer from Imported Oracle OLAP Cubes

Oracle Hyperion Financial Management Developer and Customization Guide

Salesforce Classic Guide for iphone

<Insert Picture Here>

Data Movement Modeling PowerDesigner 16.1

Siebel Application Services Interface Reference. Siebel Innovation Pack 2013 Version 8.1/8.2 September 2013

Oracle Database: SQL and PL/SQL Fundamentals NEW

BUSINESS RULES CONCEPTS... 2 BUSINESS RULE ENGINE ARCHITECTURE By using the RETE Algorithm Benefits of RETE Algorithm...

Acrobat X Pro Accessible Forms and Interactive Documents

Developing SQL and PL/SQL with JDeveloper

Official Amazon Checkout Extension for Magento Commerce. Documentation

User s Manual for Fingerprint Door Control Software

ExactTarget GENESIS I N TEGRATION GUIDE

Oracle Enterprise Data Quality. 1 JMX Binding. 1.1 Examples. Java Management Extensions Configuration Release 11g R1 ( )

Getting Started Using AudibleManager. AudibleManager 5.0

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

SAP BusinessObjects Business Intelligence platform Document Version: 4.1 Support Package Information Design Tool User Guide

DocuSign for Microsoft Dynamics CRM

Business Objects Version 5 : Introduction

ODBC Client Driver Help Kepware, Inc.

Nintex Workflow for Project Server 2010 Help

ER/Studio Enterprise Portal User Guide

Customer admin guide. UC Management Centre

Animating in Inventor Studio the basics

Quick start. A project with SpagoBI 3.x

Web Intelligence User Guide

Oracle Forms 10g Dynamic LOVs

Query JD Edwards EnterpriseOne Customer Credit using Oracle BPEL Process Manager

Oracle OLAP. Describing Data Validation Plug-in for Analytic Workspace Manager. Product Support

Financial Management System

Oracle Database: SQL and PL/SQL Fundamentals

An Oracle White Paper September Oracle Team Productivity Center

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

Oracle Database: SQL and PL/SQL Fundamentals NEW

Getting Started with Android Smartphones and ThingWorx

Oracle Fusion Middleware

Oracle WebLogic Server

ORACLE ADF MOBILE DATA SHEET

Oracle Database: Program with PL/SQL

Mahara: MyPortfolio. Create content Build pages Share. A user guide for beginners. What is Mahara?

Developing Web and Mobile Dashboards with Oracle ADF

Information Design Tool User Guide SAP BusinessObjects Business Intelligence platform 4.0 Feature Pack 3

Crystal Reports JD Edwards EnterpriseOne and World

isupport 15 Release Notes

<Insert Picture Here> Integrating Oracle Forms and a Service Oriented Architecture

Oracle Business Intelligence 11g OPN Advanced Workshop

SAP BusinessObjects Business Intelligence platform Document Version: 4.1 Support Package Information Design Tool User Guide


Oracle Fusion Middleware

Using the HOCK flash cards in Anki on Windows, Mac, mobile and web

User Manual. Version February EVS SNMP Monitoring

SQL Server 2005: Report Builder

<Insert Picture Here>

Produced by Flinders University Centre for Educational ICT. PivotTables Excel 2010

1 What Are Web Services?

1 What Are Web Services?

Creating a Web Service using IBM Rational HATS. For IBM System i (5250) Creating a Web Service using HATS 1

Readme File. Purpose. New Features. Installation Updates. Software Requirements. Hyperion Smart View for Office Release Readme.

Integrating InfoPath Forms. Paul Baker

PowerPoint. Basics. Project

Tutorial: Hybrid App Package Development. Sybase Unwired Platform 2.2 SP02

TIBCO Spotfire Automation Services Installation and Configuration

Prepare Data ArcMap Open Trees.mpk Chrome ArcGIS Online New Map Chrome Esri Blogs Chrome Local Government Resources Reflector Phone Connected

>

NEW FEATURES ORACLE ESSBASE STUDIO

Oracle Hyperion Financial Data Quality Management ERP Integration Adapter for Oracle Applications

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

An Oracle White Paper June RESTful Web Services for the Oracle Database Cloud - Multitenant Edition

Transcription:

ADF Code Corner 106. Drag-and-drop reordering of table rows Abstract: A requirement drequently posted on the JDeveloper and ADF forum on OTN is to reorder rows exposed in an ADF table. Though you cannot change the order in which existing data is stored in database tables, you can use drag and drop within a table to change the order of displayed rows. A use case for this requirement is to easily compare two rows in a table. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 18-MAR-2013

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 As shown in the images below, applying the code in this article will allow you to re-arrange rows within a table using drag and drop.the dragged row is put into the place of the row it is dropped onto. Its simply a change in the indexing of the iterator. Selecting a row and dragging it to a new location as shown in the images above and below 2

.. will then show it in its new position within the table. For this to display correctly, the table needs to be partially refreshed, causing a little flicker. Note that reordering the rows in the table will only have an effect to the DCIteratorBinding (more precise, its an effect to the RowSetIterator it decorates) in the Pagedef file. The same data in the database doesn't change and performing a re-query of the iterator data will produce the previous row order unless you dynamically change the query order according to the drag and drop of rows (which is not in the scope of this article) Implementation The image below shows the JDeveloper 11.1.2.3 workspace of the sample (Note though that this solution also works with 11g R1 applications). The row reordering for a table is built out of the af:dragsource tag that enables rows to be dragged within a table, the af:collectiondroptarget tag that takes the drop event and code in a managed bean that performs the change in the iterator index. 3

The image below shows the configuration of the dragsource tag, which consists of an Action, MOVE, and a Discimimant, "rowmove". The Discriminant is used to help the drag source and drop target to find together, which not only is required but also useful if you wanted to have multiple drag and drop implementations on a single view. The collectiondroptarget tag is configured as shown in the image below. For the drop component, the Action is set to MOVE as well (at least one action needs to be chosen that matches the action defined on the drag source) and the ModelName is set to rowmove. It is kind of unfortunate that the discriminator property naming is not consistent in ADF Faces, but at least they work as designed ;-) 4

The DropListener property references a managed bean in backing bean or request scope. The bean doesn't hold any state and therefore doesn't need to survive a single request. The signature for the managed bean method is as follows public DnDAction methodname(dropevent eventname) and is created automatically when using the arrow-down -> Edit option to built the method. Below is the listing of the commented source code of the managed bean that handles the drop for you to study and modify so it serves your use case. DepartmentsDropBean Managed Bean import java.util.iterator; import java.util.list; import oracle.adf.model.binding.dciteratorbinding; import oracle.adf.view.rich.component.rich.data.richtable; import oracle.adf.view.rich.context.adffacescontext; import oracle.adf.view.rich.datatransfer.dataflavor; import oracle.adf.view.rich.datatransfer.transferable; import oracle.adf.view.rich.dnd.dndaction; import oracle.adf.view.rich.event.dropevent; import oracle.jbo.row; import oracle.jbo.rowsetiterator; import oracle.jbo.uicli.binding.juctrlhierbinding; import oracle.jbo.uicli.binding.juctrlhiernodebinding; import org.apache.myfaces.trinidad.model.collectionmodel; import org.apache.myfaces.trinidad.model.rowkeyset; public class DepartmentsDropBean { public DepartmentsDropBean() {} /** * The dragged row takes the position of the row it is droped on. * Note that drag and drop is on the table component and to 5

* synchronize the underlying ADF model I needed to accept a * "flicker" of the table after the drop * * @param dropevent Event passed in from ADF Faces at the end of the * drag and drop operation * @return Copy.MOVE */ public DnDAction ondepartmentsrowdrop(dropevent dropevent) { //get the table instance. This information is later used //to determine the tree binding and the iterator binding RichTable table = (RichTable)dropEvent.getDragComponent(); List droprowkey = (List)dropEvent.getDropSite(); //if no dropsite then drop area was not a data area if (droprowkey == null) { return DnDAction.NONE; } //The transferable is the payload that contains the dragged row's //row key that we use to access the dragged row handle in the ADF //iterator binding Transferable t = dropevent.gettransferable(); //get the row key set of the dragged row. The "rowmove" string is the //discriminant defined on the drag source and the collectiondrop //target. DataFlavor<RowKeySet> df = DataFlavor.getDataFlavor (RowKeySet.class, "rowmove"); RowKeySet rks = t.getdata(df); Iterator iter = rks.iterator(); //for this use case the re-order of rows is one-by-one, which means //that the rowkeyset should only contain a single entry. If it //contains more then still we only look at a singe (first) row key //entry List draggedrowkey = (List) iter.next(); //get access to the oracle.jbo.row instance representing this table //row JUCtrlHierNodeBinding draggerownode = (JUCtrlHierNodeBinding) table.getrowdata(draggedrowkey); Row dragrow = draggerownode.getrow(); JUCtrlHierNodeBinding droprowobject = (JUCtrlHierNodeBinding) table.getrowdata(droprowkey); Row droprow = droprowobject.getrow(); 6

//get the table's ADF JUCtrlHierBinding CollectionModel collectionmodel = (CollectionModel) table.getvalue(); JUCtrlHierBinding treebinding = (JUCtrlHierBinding)collectionModel.getWrappedData(); //get access to the ADF iterator binding used by the table and the //underlying RowSetIterator. The RowSetIterator allows us to remove //and re-instert the dragged row DCIteratorBinding departmentsiterator = treebinding.getdciteratorbinding(); RowSetIterator rsi = departmentsiterator.getrowsetiterator(); int indexofdroprow= rsi.getrangeindexof(droprow); //remove dragged row from collection so it can be added back dragrow.removeandretain(); rsi.insertrowatrangeindex(indexofdroprow, dragrow); //make row current in ADF iterator. departmentsiterator.setcurrentrowindexinrange(indexofdroprow); //ppr the table AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance(); //note that the refresh of the table didn't work when refreshing the //table so I needed to refresh the container component //(af:panelstretchlayout). adfctx.addpartialtarget(table.getparent()); return DnDAction.MOVE; } } Download The sample application for this article can be downloaded as sample #106 from the ADF Code Corner website http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html You need to configure the database connection of the model project to point to the unlocked HR schema of a local database. Then run the "ReorderCollection.jsf" to play with this. RELATED DOCOMENTATION 7

8