Tuesday, September 29, 2009

Tab selection and Enable User Customization on Session bug.

When you have enabled User Customization for duration of session then what ever user changes on a page it remains the same through out the session, ie. Disclosed panel boxes, advanced query criteria, visible columns of tables in panel collections etc.


The problem is that you cant customize which properties to be kept or not :
Fusion Developer's Guide for Oracle ADF & 34.3 Configuring User Customizations:
Note:
If you've enabled just session persistence, then all attribute values shown in Table 34-1 will be persisted to the session. There is no way to override this either globally or on an instance.

The bigger problem is that if you have some business logic about these components appearance or behavior you can’t override user settings.

We usually have some business logic about Disclosed tab in af:panelTabbed so I created this test case.

It’s a simple page that when you enter first tab should be disclosed and when you press button ‘Select Second tab’ second tab should be disclosed.

So I set disclosed property of First tab disclosed. Also on value change listener of button I run the following backing bean method:
public void SelectSecondTab(ActionEvent actionEvent) {
this.firstTab.setDisclosed(false);
this.secondTab.setDisclosed(true);
}

This work fine when I don’t have enabled User Customization.

But when I have enabled User Customization for duration of session then page always open with disclosed tab the one that I had selected the last time I used the page and backing bean method does not select the second tab.

Is this a bug?

Shouldn’t business logic methods override user customization settings?

Test case:
http://adfbugs.googlecode.com/files/TestTabSelection.zip

Wednesday, September 16, 2009

Range Paging and Restore Current Row After Rollback workaround

We use Steve Muench example for restoring current row after rollback is executed.
http://blogs.oracle.com/smuenchadf/examples/
http://otn.oracle.com/products/jdev/tips/muench/restorecurrencyonrollback/RestoreCurrentRowAfterRollback.zip
It was working fine until we started using Range Paging on view objects.
In view objects with range paging, if you select a row in the first page of range then rollback keeps the same row.

But if you select a row that is not on the first page of range, rollback gets you to the first row or throw a null pointer exception.

Reviewing the code of afterRollback method

public void afterRollback(TransactionEvent TransactionEvent) {
super.afterRollback(TransactionEvent);
if (currentRowKey != null) {
Key k = new Key(currentRowKey.getAttributeValues());
Row[] found = findByKey(k, 1);
executeQuery();


I noticed that it was calling executeQuery() method. I moved that call tbefore the findByKey method, and then rollback restores the current row after rollback even for view objects with Range Paging :

public void afterRollback(TransactionEvent TransactionEvent) {
super.afterRollback(TransactionEvent);
if (currentRowKey != null) {
executeQuery();
Key k = new Key(currentRowKey.getAttributeValues());
Row[] found = findByKey(k, 1);


Is this magic?

Do I miss something? Or it should be like that?

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

Wednesday, September 9, 2009

Unsaved changes uncommittedDataWarning bug

I was reading JDeveloper 11g — Functional Patterns & Best Practices for unsaved changes
and decided to try it.

I created 2 task flows and 2 pages and navigation between them, normal and as dialog
In both pages i set and i run application.
I make a change in department name and press Employees Dialog.
The warning message for changes apear.

But the Employees Doesn't open as dialog!!??
When i try to return to Departments i get again the warning, even though no changes in this page and its a different task flow
So with this feature
you cannot use dialogs,
it does not rollback data
it does not depend on page or on task flow.
you cannot change the message
you cannot add custom logic on it
The only good thing about this feature is that the warning shows also when you try to close the explorer window. I wish it was working only then and it also released the application module.
test case:

Sunday, September 6, 2009

ExecuteEmptyRowSet and Range Paging. (Fixed in 11.1.2)

As andrejus showed you can reduce the time loading a page by executing Empty row set before page opens.
http://andrejusb.blogspot.com/2009/08/oracle-adf-tuning-preventing-sql-query.html


Yet this does not combine with Range Paging since getEstimatedRowCount give result in an empty row set when Range paging is used.


To test that i created an Employees view object and a method in application module that executes empty row set and estimate row count:


public long emptyRowSetCount(){
this.getEmployeesView1().executeEmptyRowSet();
return getEmployeesView1().getEstimatedRowCount();
}


this return 0 in default view object.


but if i set Employees view object Access Mode = Range paging then the method return the count of rows of the database.



The getFetchedRowCount return 0 in both cases but this is not exposed in the bindings and on the pages we usually use #{bindings.EmployeesView1Iterator.estimatedRowCount}.


In ViewObjectImpl java doc, the method executeEmptyRowSet does not have any comments, so its not clear what it does.


So i wander if this is an issue of executeEmptyRowSet or getEstimatedRowCount or Range Paging...


Test Case:
http://adfbugs.googlecode.com/files/TestEmptyRowSet.zip
Not Reproduced in jdeveloper 11.1.2