Sunday, November 8, 2009

Travel to South Africa

Yesterday I have started my trip to South Africa, and today I'm here - Hi Africa! I will deliver ADF 11g training and consulting in Johannesburg.

I was flying through Paris Charles de Gaulle International Airport, I was impressed by its architecture style:


Here is a place near my hotel in Johannesburg suburb, its build in old Italian style:


And its summer here now, all green:


Entertainment here is also good :)

Friday, November 6, 2009

Defining the LOV on a Reference Attribute in Oracle ADF 11g

Yesterday I got a question from my blog post reader about LOV components, about how to use LOV components on a reference attributes. Actually, its quite common requirement to have reference attribute shown in LOV, and not its code. I knew it from before, this functional requirement can be implemented in ADF 11g, Steve Muench described it in Oracle Magazine article year ago. However, I decided to implement sample application for this requirement and to give more light on this topic.

Download sample application - LOVByName.zip. It is based on instructions from Steve Muench article mentioned above.

I'm talking here about LOV, where description text is used directly in LOV component, and code is not shown:


User can select value from LOV popup:


And return it back:


So, what you need to do in order to make it work this way. Actually, nothing new comparing to LOV with code value. As usual, include reference attribute, key attribute will be added automatically:


Those attributes are added as reference attributes, means not updateable:


Main thing here is to declare LOV on reference attribute - JobTitle:


You should set JobTitle as LOV attribute and additionally return real key attribute - JobId:


Thursday, November 5, 2009

Calling Custom Entity Method From View Object Implementation Class

Few days ago I got a question from one of my colleagues about how to call custom method from EO implementation class. Colleague wanted to call this method from VO implementation class. I would not recommend you to follow this approach, because instead calling method in EO, you can invoke same code in VO row implementation class. But yes, exist different use cases and sometimes you may need to call EO from VO. In this post I will describe how you can do this.

Download sample application - CallingEntityMethodFromView.zip, this sample implements Java classes for EO and VO.

In EmployeesImpl.java, implementation class for EO, I have created simple custom method - calculateEmployeeRate(). This method multiplies salary with commission value per row:


Then you need to create VO and VO row implementation classes:


Create method in VO implementation class. This method should accept a row, based on this row it will retrieve EO implementation class and invoke custom method available there:


In order to make it work from ViewController, expose method you just created in VO implementation class through Client Interface:


Any exposed method can be declared in Page Definition. Pay attention for parameter value, I specified to accept current row. This means method in VO implementation always will get current row and based on it will invoke my custom method in EO:


On runtime, press Calculate Rate button that invokes custom logic in Model, and you will get result:

Wednesday, November 4, 2009

Groovy Validation Hint in Oracle ADF 11g

There is one very powerful option for Groovy validation in Oracle ADF 11g. This option is somehow hidden from developers and quite often not used. I decided to blog about it, in order to put some light on it. This option is about how to get old and new values for edited attribute. Groovy provides two reserved keywords - oldValue and newValue, you can use those keywords while writing Groovy validation script.

Download sample application - GroovyValidation.zip. This sample implements pretty simple validation rule, to demonstrate how you can use mentioned Groovy keywords:


Reserved keyword oldValue is used to implement validation logic:


Developer can specify token method expressions in validation failure message based on the same oldValue and newValue:


On runtime, if validation rule will fail, it will show current wrong value. If you will not use newValue, it will show currently in database stored value, which is not correct.

Tuesday, November 3, 2009

Business Logic Groups in Oracle ADF 11g

I was reviewing Business Logic Groups functionality in Oracle ADF BC and was getting problems - correct Business Logic Unit wasn't invoked when needed. Its because I misunderstood documentation, and was trying to configure discriminator property for attribute. Its seems everything much more simple, you just need to specify discriminator value in Business Logic Unit name. Thanks to Steve Muench for this pointer. Actually, there is a tip in documentation as well, which I skipped while reading - 4.8.2 How to Create a Business Logic Unit.

Download sample application with working Business Logic Group defined for Employees EO - BusinessGroups.zip.

In order to define Business Logic Group, you need to specify which attribute from EO will be used as discriminator to choose between available Business Logic Units:


Next step is to define Business Logic Unit. Its very important at this step to enter correct Unit Name. It should reflect discriminator value for this Business Logic Unit. In my case it is IT_PROG, for employees working as programmers. It is a place where you need to specify discriminator:


In sample application I have created two Business Logic Units, one for IT_PROG and another for ST_CLERK JobId's:


In Business Logic Unit, you need to override attributes you want to change. Then you can change those attributes properties, add validation rules. In this example I have created validation rule for overridden Salary attribute:


Another validation rule for Salary attribute is defined in ST_CLERK Business Logic Unit:


I have specified different Salary attribute labels for IT_PROG and ST_CLERK Business Logic Units:


Additionally through Business Logic Unit you can implement custom behavior in Business Logic Unit Java class:


On runtime you can see Business Logic Group related behavior for IT_PROG:


And for ST_CLERK:

Monday, November 2, 2009

Oracle ACE Presentations on Google Advertisement

Its fun, today while reading my email, I saw Google advertisement about Oracle ACE presentations on Oracle OpenWorld 2009:


It points to Oracle ACE Materials on OTN. Thanks to OTN team !

Sunday, November 1, 2009

SOA Advisory Board and BMW Oracle Racing

Here is a cool pic from SOA Advisory Board in Oracle HQ, Redwood Shores. You can see me also on a boat:

It is taken by Juergen Kress - SOA Partner Adoption blog.