Wednesday, November 10, 2010

Few Hints about ADF 11g Web Deployment Profiles

While doing different ADF 11g projects reviews, I frequently encounter situation when ADF deployment package size is multiplied at least by two, comparing to what it should be. Usually this happens because improper application libraries packaging - source code is duplicated during packaging into multiple identical libraries later included into EAR deployment distribution package. Today I will describe few hints related to this topic.

Download sample application - WebDeploymentWar.zip, where deployment profiles are set as I describe in this blog. This application contains simplistic ADF 11g project structure - one shared resources project with ADF ViewController utility classes together with Model/ViewController implementation projects:



Myself I would recommend to package shared project into ADF Library and consume it, instead of declaring direct dependency - this will improve reusability and will minimize source code duplications across different consuming projects. Shared project contains ADF Library deployment profile:


ViewController contains direct dependency only to Model project:


ViewController consumes shared resources from SharedViewUtils through library reference:


Typical mistake we are doing is inclusion of the same shared resource library into EAR application package assembly. It is enough to reference ADF Library only from consuming ViewController project, no need package it again into EAR - this will include library twice and increase EAR application package size:


If we expand generated EAR package, we will see shared ADF Library is included into WAR package and additionally it is duplicated on EAR level:


This will increase deployment package size and will consume more server resources, no one wants this - so include into EAR only required packages, everything what is referenced from required package itself should not be included again:


Its how EAR deployment package should look - ADF Library is included into WAR package, from where it is referenced:


One more hint - even all resources are referenced correctly, you still should be careful. When running application on embedded WebLogic server, you may get auto generated duplications of different deployment profiles - shared view resources are generated into WAR, even there is no such deplyment profile defined:


Deployment folder contains two WAR packages:


WebLogic is creating two Web application modules and consumes double resources because of this:


The reason of this - web.xml available in shared resources project:


Even there are no WAR deployment profile present, JDeveloper still generates WAR for project, when there is web.xml present. Remove web.xml where it is not needed:


After these fixes, only one WAR package is generated, as expected:

Friday, November 5, 2010

Red Samurai Video - Oracle Fusion Middleware and SOA Delivery Partner in EMEA

You can watch Oracle Partner Network video interview recording about Red Samurai Oracle Open World 2010 awards:


- Oracle Fusion Middleware Innovation Award Winner 2010


- SOA Partner Community Award for Outstanding Contribution Across the World 2010


- 2010 Enterprise 2.0 Blazer: Enterprise 2.0 Leader Award


Wednesday, November 3, 2010

How To Access Page Element Value from Backing Bean

I have received question from ADF newbie developer, who is starting to work with the framework. Question was simple, however I have decided to post it on the blog - simple topic for a change. It happens we work too much on complex things and forget about simple ones. Today I will describe how you can access Page Element (Input Text, etc.) value from Backing Bean.

First thing, you should register Java class as a bean. If you are working with page/fragment from bounded task flow, register it under that task flow:


There is Binding property in Advanced section, for every Page Element, it will reference component binding accessible from the bean class. I will use DepartmentName attribute in this example. Also I will declare my Page Element to have auto submit functionality - this will invoke Value Change Listener:


For the demonstration purpose, I will declare one more DepartmentName attribute value in page definition - DepartmentNameTest:


There are four different approaches implemented in the bean class. First is accessing element binding and getting its value. Another approach works with current row from iterator. Third approach is accessing attribute value from page definition. I prefer this approach, it makes implementation more loosely coupled and independent from the model refactoring. There is fourth approach as well - to get new value from value change listener directly:


We can press Test button, DepartmentName value will be accessed in the bean class:


Value is accessed:


DepartmentName value is changed:


Accessed from value change listener:


Download sample application - InputTextValueAccess.zip

Thursday, October 28, 2010

Initializing Oracle BPM 11g Process Payload from Oracle ADF 11g

Oracle ADF 11g is a key framework for Oracle Fusion Middleware 11g family products, same applies for Oracle BPM 11g Suite. When it comes time to application implementation on top of defined processes - its when Oracle ADF 11g comes into picture. I will present today fairly simple BPM process and will describe how we can initialize process payload with real data from database using ADF.

We can assume initial process looks like the following:


It implements two Human Tasks defined for two different roles - TeamLeaders and ProjectManagers. The logic is simple - TeamsLeaders role can initialize the task and ProjectManagers role can approve it. Download sample application for today post - EmployeeManagementLab.zip.

Process payload is initialized from Initialization activity, using dummy payload script:


I will remove this initialization script and will explain how you can initialize payload with real data from table selection:


I will retrieve initialization data from ADF BC project, you can base your Model on Web Service or EJB - no difference, ADF provides unified Data Control for different Model implementations. My ADF BC project based on HR database schema:


ADF Task Flow Human Task project for process initialization role is auto-generated from Oracle BPM 11g directly:


In this example I'm using default auto-generated ADF Task Flow for Human Task:


Auto generated ADF Faces screen for Human Task looks similar:


I have drag&dropped Panel Collection component from ADF Faces Components palette, its where Table component will be defined:


You should expand Data Controls tab to see available data collections and methods. In this example I want to create table component with Employees data, user will be able to select one Employee and enable process payload with this data:


I can create data bounded table on Employees data collection, just by drag&drop from Data Controls:


Save and Undo operations also are provided by Data Control:


Now is one of most important steps to understand - we must have attributes defined from both data collections (BPM process payload and Employees table) in Page Definition. Attributes for BPM process payload form are auto-generated, we need to define attributes that represent Employees collection by ourselves - this will allow to access currently selected row:


All attributes for Employees collection:


Every attribute is pointing to the same iterator, it brings data from ADF BC Data Control:


Next step is to override Table component selection listener, we need to process table selection event and assign payload programmatically:


Selection listener is overridden using SelectionListener table property, it should point to the Java bean method:


Java bean is created as simple Java class:


This class is declared in ADF Bounded Task Flow, same task flow where Human Task is auto-generated:


Selection listener is overridden inside Java bean class:


Inside selection listener, first we are processing table selection event. Next, using ADFUtils class helper methods, we are copying values from currently selected row into BPM process payload:


There are various approaches to copy values from one collection into another, for example you can access iterator directly and get current row, then you will need to operate with real attribute names defined in Data Control. I prefer to operate through defined Attributes, this allows to be independent from naming changes in Data Control.

Values are copied into payload, additionally we need to set Partial Trigger refresh relationship from Employees table to process payload form - to show payload changes based on different row selection:


This can be achieved both declaratively and programmatically, I will go with Java coding approach in this sample. Mainly because declarative approach will trigger refresh always, however in the future I will want to be it conditional. I need to set Binding property for payload form, this will allow to operate it from code:


Binding is defined in same Java bean, where we have selection listener:


It is enough to use defined binding from standard ADF API to send partial refresh event from table to form:


I'm running Oracle BPM 11g functionality inside WebCenter Spaces 11g through standard BPM 11g ADF Task Flows, user custom ADF Task Flows additionally are present as well - Oracle BPM/WebCenter Spaces 11g screen:


Employee assignment process is initialized from Oracle WebCenter Spaces 11g. Table data is retrieved from ADF BC, user selects row and automatically populates process payload form available on the left:


If user selects another row, payload form is updated as well:


Now we can login as another user - redsam2, who is assigned with ProjectManagers role, this role is designed to approve process and should received incoming tasks initialized with payload:


We can see several incoming tasks available:


Payload data is set correctly - task can be approved or rejected: