Tuesday, December 22, 2009

Composition Association and Locking (Fixed in 11.1.1.4)

We had a lot of locking problems in our ADF application even though we use optimistic locking.

We found out that it was caused by composition Association and Lock Top Level Container Option.
This is the default way the association is generated by the wizard when the foreign key constraint in database is cascade.
In my test case I set it by hand to reproduce in Department Employees relationship.


The master Entity Table in database is locked every time you create a new record in the detail composed entity.
This is happening when creating detail data and not when posting data as in optimistic locking
This does not happen when you update or delete data from detail entity.

Is this a bug?

If pessimistic mode of Application Module is not a good practice for Fusion Applications then composition Association Locking should also be not.

Composition Association is a rule to prevent details to exist without a master. But this is also prevented if the foreign key attribute in detail entity is required. So I also don’t see the usage of composition association.

Test Case:
http://adfbugs.googlecode.com/files/TestCompositionLock.zip

Wednesday, December 16, 2009

GoMenuItem and GoLink with target="_Blank" don't work correctly inside a Menu

We have strange behavior with GoMenuItem and GoLink components inside menu items

To reproduce the problem i created the following simple test case:
Created a menu with 2 levels and gomenuItems and MenuLinks that all open 'otn' in new '_blank' window.


The menu is the following:


1. In the menu above if i select goMenuItem 1 then new window opens behind my window (internet explorer 7,) works correctly in mozilla. goMenuItem 2 works correctly in ie7 also.

Funny thing is that if in ie7 you have a second tab opened then it works correctly.

2. goLink 1 works correctly, goLink 2 does nothing.

Is this a bug? any workaround?

test case:
http://adfbugs.googlecode.com/files/TestGoMenuItem.zip

Monday, December 14, 2009

Pending changes in ADF application

So far I have seen 2 ways to check if there are pending changes in ADF application

1 is from ApplicationModule.getDBTransaction().isDirty();

2. is from DataControlFrame.isTransactionDirty();

Yet their functionality is not the same.
To demonstrate it I created a master –Detail, Departments - Employees test case with backing bean that return :

public String getAmChangesExist() {
BindingContext bc = BindingContext.getCurrent();
ApplicationModule am = bc.getDefaultDataControl().getApplicationModule();
return am.getTransaction().isDirty()?"True":"false";
}

public String getDcFramechangesExist() {
BindingContext bc = BindingContext.getCurrent();
String currentDataControlFrame = bc.getCurrentDataControlFrame();
return bc.findDataControlFrame(currentDataControlFrame).isTransactionDirty()?"True":"false";
}

If I change anything on department(except TransientAttribute) or employees and press submit then both methods show there are pending changes.



Yet if I change value of transient attribute only dataControlFrame.isTransactionDirty() shows there is a change, and am.getTransaction().isDirty() shows false


If I press button createInsert on Department or on Employees then again :
dataControlFrame.isTransactionDirty() shows there is a change, and am.getTransaction().isDirty() shows false
I feel that changes should not include transient attributes that dont exist in entities, since they are not used in transaction.
But it should include new rows created on views and entities.
In order to be sure i would chose dataControlFrame.isTransactionDirty() since it also keeps its value even with diferent application modules through task flows with shared data control scope.
Test case:

Sunday, December 6, 2009

Dynamic Region UIShell

I had created a Dynamic Region Template before the release of new jdeveloper patch.
Since there is a lot of discussion about the new Oracle UI Shell I decided to share it as I feel it is:
  • Simpler
  • Easier to use
  • Uses Dynamic Regions to navigate to different task flows
  • Provides customized functionality about navigating while having pending changes
  • Supports security permission check for navigating between task flows
The source code of the DynamicUIShell is here.


I also created a demo application based on HR schema, that uses this template to show the functionality. http://adfbugs.googlecode.com/files/TestDynamicUIShell.zip

In this demo you can run test page and see the functionality.
You can navigate between Home, employees and departments task flows.


If you make a change and try to navigate to an other task flow a popup raises and rollback if you chose continue.


If you try to navigate to Secured task flow a popup inform you that you don't have permission.


How to use Dynamic Region UIShell

Just import the jar file in your view controller project.



Then when you create a new JSF page you can select the template 'DynamicUIShell'.




Now you have the page based on the template.




First thing needed is to define the DefaultRegion , the task flow to be rendered in main area when the page is loaded.



i.e. f:attribute name="DefaultRegion" value="HomeTaskFlow"
Now the page should be functional and display the DefaultRegion task Flow.

Adding navigation components.

You can add now navigation components in facets like Global, TopMenubar, LeftToolBar.
Navigation components can navigate to other pages or display a different Task Flow in the main area.
In order for navigation components to be functional 2 properties are needed:
ActionListener should call navigate method of dynamicRegion managed bean (that exist in library).
Id of the component must be the path and name of task flow inside WEB-INF (with / character replaced with _):


Adding pending changes popup.

In order for pending changes to be checked a popup is needed to be added to your page, with your custom message and a Continue button.
The popup must be binded to dynamicRegion managed bean changesExist popup
The Continue button must have actionListener to dynamicRegion managed bean method continueNavigation method.
If you want to Rollback before navigation the Rollback action must exist in page definition.


Adding no permission popup

In order to check permission (taskFlowViewable) you need to add a popup on your page binded to noPermissionPopup of dynamicRegion managed bean.


Also when security is enabled in your application don't forget to allow access also to the template. To see the template in your jazn-data you need to select 'Show web pages imported from ADF libraries' check box.



Any feedback is usefull.