ADF Code Corner How-to restrict the list of values retrieved by a model driven LOV. Abstract: twitter.com/adfcodecorner

Similar documents
ADF Code Corner How-to enforce LOV Query Filtering. Abstract: twitter.com/adfcodecorner

ADF Code Corner. 016-How-to customize the ADF Faces Table Filter. Abstract: twitter.com/adfcodecorner

ADF Mobile Code Corner

ADF Code Corner. 70. How-to build dependent list boxes with Web Services Business Services. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to further filter detail queries based on a condition in the parent view using ADF BC. Abstract: twitter.

ADF Code Corner. 90. Filtering ADF bound lists. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to declaratively build a master-detail behavior with DVT components. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to use the af:autosuggestbehavior component tag with ADF bound data sources. Abstract: twitter.

ADF Code Corner. 64. How-to implement a Select Many Shuttle with pre- selected values. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to launch a popup upon rendering of a page fragment in a region using JSF 2. Abstract: twitter.

ADF Code Corner How-to bind custom declarative components to ADF. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to build a reusable toolbar with Oracle ADF Declarative Components. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to show a glasspane and splash screen for long running queries. Abstract: twitter.com/adfcodecorner

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

ADF Code Corner How to cancel an edit form, undoing changes with ADFm savepoints

ADF Mobile Code Corner

ADF Code Corner. 048-How-to build XML Menu Model based site menus and how to protect them with ADF Security and JAAS. Abstract:

ADF Code Corner. 65. Active Data Service Sample Twitter Client. Abstract: twitter.com/adfcodecorner

ADF Code Corner Implementing auto suggest functionality in ADF Faces. Abstract:

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

ADF Mobile Code Corner

ADF Code Corner. 97. How-to defer train-stop navigation for custom form validation or other developer interaction. Abstract: twitter.

ADF Code Corner. 71. How-to integrate Java Applets with Oracle ADF Faces. Abstract: twitter.com/adfcodecorner

Oracle JDeveloper/Oracle ADF 11g Production Project Experience

The Tie That Binds: An Introduction to ADF Bindings

ADF Mobile Code Corner

<Insert Picture Here> Advanced ADF Faces. Frank Nimphius Principal Product Manager

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

Oracle ADF 11g: New Declarative Validation, List of Values, and Search Features. Steve Muench Consulting Product Manager Oracle ADF Development Team

Introduction to ADF Core Technologies

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

ADF Hands-On. Understanding Task Flow Activities / 2011 ADF Internal Enterprise 2.0 Training. Abstract:

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

Oracle ADF On Ramp: What You Need to Know to Use ADF

Oracle Retail Accelerators for WebLogic Server 11g

<Insert Picture Here> The Oracle Fusion Development Platform: Oracle JDeveloper and Oracle ADF Overview

Oracle ADF On-Ramp: Developing Applications With the Core ADF Stack

Mastering Oracle ADF Task Flows. Frank Nimphius Principal Product Manager Oracle JDeveloper / ADF

<Insert Picture Here> Accelerated Java EE Development: The Oracle Way

Getting started with ADF 11g

ADF Code Corner How-to use Captcha with ADF Faces and Oracle ADF. Abstract: twitter.com/adfcodecorner

Rich Web UI made simple Building Data Dashboards without Code

ADF OAF Who Cares? You Do! Oracle Applications Framework / Application Development Framework - Which way do I go?

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

Oracle Developer Day

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

Oracle Application Development Framework Overview

Oracle Fusion Middleware

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

Oracle Exam 1z0-419 Oracle Application Development Framework 12c Essentials Version: 7.0 [ Total Questions: 87 ]

Oracle Developer Day

Customizing Oracle Identity Governance: Populating Request Attributes

Different color bars chart with Popup Box in ADF

Oracle Middleware 12c: Build Rich Client Applications with ADF Ed 1 LVC

ADF On-Ramp: What You Need to Know to Use the ADF Fusion Technology Stack. What is ADF and Fusion? ADF core technologies. Required languages.

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

ADF Desktop Integration 11g Release1 Component and Feature Demo

<Insert Picture Here> Oracle Policy Automation Connector For Siebel Features and Benefits

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

<Insert Picture Here> Oracle Application Framework (OAF): Architecture, Personalization, and Extensibility in Oracle E-Business Suite Release 12

Real Application Security Administration

Take Your Oracle Forms on the Road Using ADF Mobile. Mia Urman, OraPlayer & Denis Tyrell, Oracle Corporation

ADF Region Interaction: External Train Navigation

If you wish to make an improved product, you must already be engaged in making an inferior one.

Achieving the Perfect Layout with ADF Faces RC

<Insert Picture Here> How to Debug Oracle ADF Framework Applications

Oracle Fusion Middleware

Oracle Developer Day

Oracle Fusion Middleware

Oracle Database. Installation and Configuration of Real Application Security Administration (RASADM) Prerequisites

Oracle Fusion Middleware

Sun Java Studio Creator. Ken Paulsen Staff Engineer Sun Microsystems, Incorporated (Slides by: Craig R. McClanahan)

Building Rich Enterprise JSF Applications with Oracle JHeadstart for ADF (11.1.1)

Oracle Fusion Middleware 11g: Build Applications with ADF I

<Insert Picture Here> The Latest E-Business Suite R12.x OA Framework Rich User Interface Enhancements

<Insert Picture Here> Oracle JHeadstart Forms2ADF - Overview

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

Case Study: Redeveloping an Oracle Forms application using Oracle JDeveloper and Oracle ADF

ADF Code Corner. Oracle JDeveloper OTN Harvest 12 / 2011 & 01 / Abstract: twitter.com/adfcodecorner

Process Document Creating a Query with Runtime Prompts. Creating a Query with Runtime Prompts. Concept

Go to /Jdevbin/jdev/bin Double click on Jdevw.exe

Safe Harbor Statement

ORACLE JHEADSTART 12C for ADF

Using Thick Database Principles to Leverage Oracle SQL and PL/SQL Part III:

Diagram Based UIs in Oracle ADF

Developing an ADF 11g client for Agile PLM. Developing an ADF 11g client for Agile PLM

Oracle Banking Platform UI Extensibility Guide Release

Oracle Fusion Middleware

Oracle Fusion Middleware

Oracle WebCenter Suite Integrating Secure Enterprise Search

Quick Web Development using JDeveloper 10g

Oracle ADF: The technology behind project fusion. Lynn Munsinger Principal Product Manager Application Development Tools Oracle Corporation

Oracle Fusion Middleware 11g: Build Applications with ADF I

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

<Insert Picture Here> JDeveloper Treasure Hunt

ADF On-Ramp: What You Need to Know to Use ADF. What is ADF and Fusion? ADF core technologies. Required languages. Survey. Agenda. On the Positive Side

Exam Questions 1Z0-419

A Closer Look at XPages in IBM Lotus Domino Designer 8.5 Ray Chan Advisory I/T Specialist Lotus, IBM Software Group

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

Oracle Fusion Developer Guide (ISBN: ) Preview Chapter 1. The Quick Lerner s Guide to Oracle Fusion Web Application Development PREVIEW

Transcription:

ADF Code Corner 044. How-to restrict the list of values retrieved by a model Abstract: A new feature of the Oracle ADF Business Components business layer in Oracle JDeveloper 11g is model driven List of Values (LOV). Using model, the list resource is configured on the View Object attribute for which the list of values should be shown. Usecases may demand that the list of values should be filtered by the current user responsibility. For example, the sales manager for North America should not see customers from other regions when using a LOV in a new sales forecast. Others may want to use this as a security precaution in that the filter should not unveil any information that is not supposed to be seen by the authenticated user. In both cases the user is member of a role that is either a security role or a business role. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 07-Feb-2010

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 This how-to does not explain how to create model in ADF Business Components and other web resources exist that describe this. We start from the assumption that a model driven LOV definition is created for the "DepartmentId" attribute of the Employees View Object and that the list source points of the Departments View Object. Also we assume that the LOV UI setting is defined so an input text with LOV is used. Bind variables One option to implement this usecase is to create a bind variable on the Departments View Object and use it in the where clause of the query. As shown in the image below, the bind variable deptid is defined in the VO and added to the query where clause. The displays hint of the deptid variable is set so "hide", which is important as otherwise, the variable shows as a search field in the LOV. 2

The ADF Faces RC input form is created by dragging the Employees View object to the JSF page, choosing Forms ADF Form from the popup menu after releasing the drag operation. The DepartmentId attribute automatically is rendered as a LOV component that shows its value in a text field. This is the beauty of model driven list of values, which I think is a cool feature added in this release. At least, it demos well ;-) The page code for the list of value component is shown below <af:inputlistofvalues id="departmentidid" popuptitle="search and Select: #{bindings.departmentid.hints.label" value="#{bindings.departmentid.inputvalue" label="#{bindings.departmentid.hints.label" model="#{bindings.departmentid.listofvaluesmodel" required="#{bindings.departmentid.hints.mandatory" columns="#{bindings.departmentid.hints.displaywidth" shortdesc="#{bindings.departmentid.hints.tooltip" launchpopuplistener="#{lovtestbean.onlovlaunch"> <f:validator binding="#{bindings.departmentid.validator"/> <af:convertnumber groupingused="false" pattern="#{bindings.departmentid.format"/> </af:inputlistofvalues> Well spotted! The af:inputlistofvalues component has a launchpopuplistener defined, and its this listener that sets the query filter for us. The managed bean code is shown below and sets a - in this example - hard coded value to the bind variable defined in the View object public void onlovlaunch(launchpopupevent launchpopupevent) { lov.getlistiterbinding().getviewobject().setnamedwhereclauseparam("deptid","60"); Using this listener, restricts all values shown in the LOV to those that at least have a department id of 60, which in the case of the Department View Object is one entry, but you get the idea. Note that "DepartmentId" in the code line (FacesCtrlLOVBinding)bindings.get( "DepartmentId"); references the attribute binding of the input list of value component in the pagedef file. Using appending a where clause When a bind variable cannot be used, or if the where clause needs to be complex then appending the where clause from the launchpopuplistener is an option to use. So modifying the managed bean to the code sample shown below will list all entries for the departments 30,40,50 and 60 if the LOV is queried for all records. public void onlovlaunch(launchpopupevent launchpopupevent) { 3

String wcl = "department_id in (30,40,50,60)"; lov.getlistiterbinding().getviewobject().setwhereclause(wcl); Using named ViewCriterias Now that I showed you all that works, let me show you what I like the best and think probably is best practices too. View Criterias are one-time where clauses added to a query. In JDeveloper 11g, you can define named view criterias that so that all developers that need to append a where clause can use a consistent definition, making it easier to enforce best practices and audit application business rules. ViewCriteria can be created with or without bind variables, where the bind variables used can be defined as "optional" - or not required - which means that the View object could be used without populating the bind variable, solving the limitation that exist when hard coding the variable usage into the View object query where clause. 4

Lets create the same two samples using View Criteria on the Departments View object First, query for departments between 30 and 60. The launchpopuplistener code for this is shown below: public void onlovlaunch(launchpopupevent launchpopupevent) { ViewCriteriaManager vcm = lov.getlistiterbinding().getviewobject().getviewcriteriamanager(); ViewCriteria vc = vcm.getviewcriteria("departmentsbetween30and60"); lov.getlistiterbinding().getviewobject().applyviewcriteria(vc); Instead of using the where clause on the View object, the listener queries the ViewCriteriaManager for the "DepartmentsBetween30and60" ViewCriteria to apply it to the VO. However, more likely you need to filter the LOV dialog more dynamic than this. For this you can use the code shown below, which dynamically creates a view criteria and applies it to the LOV query. Using the code sample below, you can filter the LOV using all queryable attributes of the View Object you use for populating the LOV search popup. In the sample below, the LOV is pre-filtered by the DepartmentId, which I set to 60 (however, the example is flexible) 5

public void onpopuplaunch(launchpopupevent launchpopupevent) { ViewCriteriaManager vcm = lov.getlistiterbinding().getviewobject().getviewcriteriamanager(); //make sure the view criteria is cleared vcm.removeviewcriteria(vcm.dflt_view_criteria_name); //create a new view criteria ViewCriteria vc = new ViewCriteria(lov.getListIterBinding().getViewObject()); //use the default view criteria name //" DefaultViewCriteria " vc.setname(vcm.dflt_view_criteria_name); //create a view criteria row for all queryable attributes ViewCriteriaRow vcr = new ViewCriteriaRow(vc); //for this sample I set the query filter to DepartmentId 60. //You may determine it at runtime by reading it from a managed bean //or binding layer vcr.setattribute("departmentid", 60); vc.addrow(vcr); lov.getlistiterbinding().getviewobject().applyviewcriteria(vc); If you want to use a named view criteria defined at design time instead of a dynamically created one, you can define a named view criteria with all queryable attributes (no bind variables, just the attributes you want to query when filtering the LOV view object) in the View Object editor and apply it at runtime by its name. For example, if the named view criteria you design at runtime is named "myqueryablevc" then the code above needs to be slightly changed as shown below public void onpopuplaunch(launchpopupevent launchpopupevent) { ViewCriteriaManager vcm = lov.getlistiterbinding().getviewobject().getviewcriteriamanager(); //make sure the view criteria is cleared vcm.removeviewcriteria(vcm.dflt_view_criteria_name); //create a new view criteria ViewCriteria vc = vcm.getviewcriteria("myqueryablevc"); ViewCriteriaRow vcr = new ViewCriteriaRow(vc); vcr.setattribute("departmentid", 60); vc.addrow(vcr); lov.getlistiterbinding().getviewobject().applyviewcriteria(vc); 6