Dynamically Assigning Named Bind Variable Default Values

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:26:41 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Dynamically Assigning Named Bind Variable Default Values

One of the interesting coding techniques in the SRDemo Sample application that I ran out of time to properly describe in the ADF Developer's Guide for Forms/4GL Developers was a neat bit of generic code that allows you to dynamically default the value of named bind variables. You can read more about what framework extension classes are and how to use them in Chapter 25, "Advanced Business Components Techniques" of the guide.

It is an example of generic framework functionality that "kicks in" based on the presence of custom metadata properties on a named bind variable. See section 25.3.3 "Implementing Generic Functionality Driven by Custom Properties" in the dev guide for more details. Using this sample code, if you add a bind variable to a view object, and define a custom metadata property named DynamicDefaultValue on that bind variable, and set this custom metadata property to the value CurrentUser, then that bind variable will have its value dynamically defaulted to the name of the authenticated user logged in. If instead you set this custom property to the value UserRole, then the bind variable will be set to the comma-separated string containing the list of roles that the authenticated user belongs to.

Once you've created a framework extension class for view objects like this, you can have the view objects you create inherit this generic functionality.See section 25.1.4 "How to Base an ADF Component on a Framework Extension Class" in the dev guide for more info on this.

By adapting a technique like this (or some idea similar that better suits your needs) you can have your view object query contain bind variables whose values automatically take on the defaults based on something in the user-session environment.

© Copyright 2008 Steve Muench. Click here to send an email to the editor of this weblog.
Last update: 2/3/2008; 9:26:41 PM.