Thursday, December 29, 2011

Groovy with View Link Accessor

My last post this year, I'm closing 2011 with #106 posts and will resume early 2012 (already next week).

This post is based on question logged on our public Wiki (Red Samurai Ora-Bug Tracker) - reference attributes in other view objects using groovy. Developer was asking how to access attributes from different View Objects using Groovy. Answer - attributes can be referenced using Groovy by View Link Accessor name, similar as we can reference in Entity Object by Association name. Pros and cons are discussed as well, and why I prefer standard View Object join.

Download sample application - ViewLinkGroovyApp.zip. In order to reference another View Object attribute through View Link Accessor, first we need to check if View Link Accessor is exposed in View Object. In this example I would like to reference City attribute from Locations, in Departments View Object. As we can see, View Link Accessor is not exposed yet in Departments:


Let's edit accessors and select to be exposed in Departments, as LocationsView name:


View Link Accessor is exposed in Departments and can be referenced through Groovy:


Add new transient attribute in Departments View Object - LocationCity:


Set default value as Expression and type such Groovy statement - LocationsView.City:


This will access referenced View Object (Locations) on runtime. You should be aware, ADF will execute two SQL statements to render Departments data (instead of one by default). Second executed statement will be generated to populate Groovy script expression:


I would recommend better to use standard View Object join, based on Association - it will retrieve same value directly using SQL join, without forcing to execute second SQL statement from Groovy.

Open Entity Objects section and define SQL join based on Entity Object association:


Add new attribute from joined Entity - City attribute:


Referenced attribute will retrieved through SQL join:


I wish you great start in 2012 !

Wednesday, December 28, 2011

ADF Train - Apply Custom Train Stop Icons

This post is based on ADF Code Corner article from Frank Nimphius - 93. Put a different Look to your Train Stop. Frank describes how we can control and customize ADF Train rendering. Recently I had similar requirement, additionally it was required to change standard ADF Train Stop icons with custom ones. In order to implement this requirement, I was following steps from ADF Code Corner sample #93, plus few minor additions.

I didn't wanted to use ADF Skin to customize ADF Train look and feel, but control rendered icons directly. Download sample application with applied custom icons for each stop - ADFTrainApp.zip.

Sample ADF Train contains three stops:


ADF Train UI component is implemented inside ADF Fragment UI template - no need to duplicate ADF Train UI inside each fragment. Comparing to ADF Code Corner sample #93, one more property is declared - icon. This property points to managed bean method, where based on currently rendered train stop we return icon to be assigned for current stop:


Method retrieves activity ID for currently rendered ADF Train Stop and returns associated icon:


Here is how our customized ADF Train looks - first stop is for General:


Second stop is for Details:


Third stop is for Payment:


Saturday, December 24, 2011

SOA & WebCenter & BPM & WebLogic Partner Communities Event Invitation

INVITATION TO

FUSION MIDDLEWARE PARTNER COMMUNITY FORUM 
SOA & WebCenter & BPM & WebLogic Partner Communities

Do you want to learn about how to sell the value of Fusion Middleware by combining SOA, BPM and WebCenter Solutions?

We would like to invite you to become updated and trained at our Fusion Middleware Partner Community Forum on February 7th and 8th 2011 at the NH Hotel in Malaga, Spain.


The event is a wonderful opportunity to:
  • learn how to sell the value of Fusion Middleware by combining SOA and WebCenter solutions
  • meet with Oracle SOA, BPM and WebCenter Product management
  • exchange knowledge and have access to competitive intelligence
  • learn from successful SOA, BPM, WebCenter and ADF implementations
  • learn about WebCenter Sites
  • network within the Oracle SOA Partner Community and the Oracle WebCenter Partner Community
During this highly informative event you can learn about partner success stories, participate in an array of break out sessions and exchange information with other partners.



Red Samurai will be doing ADF/WebCenter Master Class session together with colleagues from InfoMentum and VASSIT.

Wednesday, December 21, 2011

How to set EAR Version for ADF Application on WebLogic

If it happened to deploy ADF application on WebLogic, most likely you noticed that it assigns default version V2.0 for each ADF deployment. We would like to set our own specific version, instead of having V2.0 assigned by default:


This can be achieved by creating Manifest file inside root src/META-INF folder:


You must create Manifest file by yourself and it should be visible under META-INF descriptors from JDeveloper:


ADF application version is specified by Weblogic-Application-Version parameter inside Manifest file:


Register Manifest file with application deployment profile - include Manifest under EAR options:


Make sure to remove Manifest file from Application Descriptor filters - otherwise file will be included twice and deployment fail:


Application with our predefined version is deployed. Previos version is not removed, but is retired - we can remove it later or restore if needed:


Download sample application, it includes sample Manifest file - ADFVersionApp.zip.

Thursday, December 15, 2011

ADF Tree - How to Autoselect/Deselect Checkbox

If you want to add selection checkbox to ADF tree, read this post - ADF Tree - How to Add Checkbox. Today I will describe how to implement auto-selection for the same checkbox. Checkbox selection will be calculated using Groovy, based on additional helper attribute.

Download updated sample application - TreeCheckboxApp_v2.zip. This sample is extended with additional helper attribute on EO level, for Regions and Countries EOs. This is transient String type attribute - RegionConfirmedStatus for Regions EO:


RegionConfirmed boolean attribute value is calculated trough Groovy, based on RegionConfirmedStatus character value - Y = true, else = false. This is required, otherwise boolean value is not changed directly. It works well, when value is calculated from Groovy:


Same for Countries EO - CountryConfirmed attribute:


On UI, ADF UI component - selectBooleanCheckbox, should be configured with value change listener and enabled with auto submit - this allows to catch checkbox change event:


Value change listener is not changing boolean value directly, but is changing only helper attribute value (Y/N). When change is performed, Groovy is fired on EO level and recalculates main boolean attribute value used for checkbox. If we would change boolean value directly, this value is not preserved and is reset back to original value during next refresh. Helper attribute value is changed for Regions level as well as for Countries level (iterating over detail collection):


Implemented functionality - user selects top level node - dependent child nodes are auto-selected (and opposite on deselect):


Monday, December 12, 2011

ADF Tree - How to Add Checkbox

This is common request - to add checkbox next to ADF tree nodes. Obviously we should use ADF selectBooleanCheckbox component - however selectBooleanCheckbox is not propagated across ADF tree levels by default (applies to all ADF 11g versions). This post provides sample application for selectBooleanCheckbox rendering on different ADF tree node levels.

Download sample - TreeCheckBoxApp.zip (tested with ADF 11g R1 PS3/PS4).

Implemented tree renders two levels (Regions -> Countries):


Both level nodes are rendered with checkboxes. Checkbox is rendered based on transient EO attribute, Boolean type for Regions:


Same type attribute for Countries:


ADF tree binding contains both - Regions node name and checkbox definitions:


Similar binding for Countries:


ADF UI implements tree table (with selectBooleanCheckbox), first tree level is rendered from nodeStamp. As you can see both levels are getting values from node variable:


Let's run such tree - disabled checkboxes are rendered for empty level nodes - this is wrong:


How we can fix this? Add rendered expression for both selectBooleanCheckbox components. First level checkbox should be rendered only when RegionName is not Null:


Second level accordingly, when CountryName is not Null:


Now checkboxes are rendered correctly with ADF tree:


Sunday, December 11, 2011

Tuning ADF Tree - Retain View Link Accessor Rowset

When expanding ADF Tree node, by default - each time ADF generates new SQL statement to retrieve expanded tree level nodes. New SQL statement is generated even after collapsing and expanding same node. In most of the cases, especially when tree structure is static, we would like to avoid multiple SQL invocation for the same nodes. This can be achieved by setting Retain View Link Accessor Rowset option for View Object tuning.

Download sample application - RetainViewLinkAccessorApp.zip. This sample implements 3 levels tree structure: Locations -> Departments -> Employees:


When user expands same node of Locations (top level) two or more times, we want to retrieve previously queried Departments rows from cache, instead of querying from database again. Go to Locations tuning section and set Retain View Link Accessor Rowset setting - this will enable Departments rowset caching:


Set the same setting for Departments (second level), this will cache Employees rowset:


Employees View Object represents tree leafs and can't be expanded - means no need to set tuning option (there will be no children):


When top level Locations node is expanded, SQL is generated to retrieve corresponding Departments rowset (if Locations node will be collapsed and later same node expanded again - no SQL will be generated, rowset will be retrieved from memory). SQL is generated only first time, because of our tuning - it will not be generated during subsequent collapsing/expanding of the same node:


Tree structure:


Saturday, December 3, 2011

Fix Rowset is Forward Only Error for ADF BC LOV Range Paging (11.1.2.1.0)

This post is based on latest production JDeveloper - 11g R2 (11.1.2.1.0). ADF BC applications typically are working with database, when SQL statements are complex and slow - its good to apply Range Paging for VO's in ADF BC. Range Paging enables ADF BC to prepare SQL statement to retrieve only predefined subset of rows from database - significantly improving data retrieval performance. LOV is one of the elements in ADF applications where we can expect lots of rows to be retrieved - means good candidate to apply Range Paging.

However, if you try to apply Range Paging for LOV - it will not work. Wait wait..., but there is a workaround I will describe today. Download sample application where Range Pagine for LOV is working - LOVRangePagingFix.zip.

First, how to define Range Paging for LOV? Open LOV VO (or alternatively you can define it directly through LOV View Accessor - no difference) and expand Tuning section. Change Access Mode property to Range Paging and set Range Size (in this example is set to 30, means ADF BC will prepare SQL select to query 30 rows only for current rowset):


Next define LOV, by specifying List Data Source, etc.:


Choose Input Text with List of Values as list type:


Drag and drop LOV on ADF UI and run application. You will get Rowset is forward only error:


I will tell you, how to fix this. Open VO, where LOV is defined - from structure window locate LOV definition in the source code:


Here is the trick, even we have defined our LOV to work with Range Paging, LOV wizard ignores this and sets default ListRangeSize = -1 (inside List Binding):


Its why it fails on runtime with Rowset is forward only error - LOV VO is enabled with Range Paging, but LOV binding itself gets configured by wizard to retrieve all rows (-1). In order to fix this, set ListRangeSize = 30 by yourself (same as Range Paging):


It works well now, form is rendered:


LOV is opening, Range Paging is applied:


Selected LOV value is retrieved and set: