« January 18, 2007 | Main | January 30, 2007 »

January 22, 2007 Archives

January 22, 2007

Table Range Not Reset After Query


A customer contacted me with the following problem:
he created an ADF Faces page where
the end-users can enter a query criterion, say a Department Number, and display
the Employees from this Department in a Read-Only Table.

Dept10_Range2:


The application works fine.
However, they reported the following problem:
they can navigate to another Range in the page, to scroll through the employees of the department, as shown in the figure above, where the second Range (record 3) is displayed (I set the RangeSize to 2 in this sample).

Then they query another department, say 20.
Employees from this Department are shown - that's correct.
However, they were expecting the table to show the first employees of the Department 20.
It doesn't: the table Range stayed at the same position as it was before the new query was executed:

Dept20_Range2:


To fix this problem, you have to add the following code in your backing bean:

public String resetRange() {
   getEmpTable().setFirst(0);
   return null;
}
where table.setFirst(0) sets the index of the first row in the currently range of rows to the first record in the Table.

and set the property action of your commandButton to call this code:

<af:commandButton
   text="Query"
   (...)
   action="#{yourBackingBean.resetRange}"/>

I've added example # 4 in my Sample Applications page. It includes a page showing the problem, and another one including the workaround.


About January 2007

This page contains all entries posted to Didier's Blog in January 2007. They are listed from oldest to newest.

January 18, 2007 is the previous archive.

January 30, 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle