Wednesday, December 8, 2010

Sorting a Transient ViewObject

Transient ViewObject is a value holder for non persistable data. In this post I'm sharing a very simple example illustrating the built in sorting support for a transient ViewObject. Please note that if you have table built using a transient ViewObject, a click on the sort icon for a column in turn would invoke ViewObjectImpl::setSortBy(String sortBy) to perform in memory sorting. Whereas for a non transient VO, sorting is done by setting the OrderByClause using ViewObjectImpl::setOrderByClause(String orderByClause). This example is built based on the above theory :). I'm populating the the rows programmatically from the overridden ViewObjectImpl::executeQueryForCollection(...) and the rest is taken care by the framework. Please see Fusion Developers Guide to know the key framework methods to override for programmatic View Objects

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

How to run this sample?

Run the main.jspx and try sorting the table columns.

7 comments:

Anonymous said...

Thanks for the example, it is a helpful information when you work with programatic VO.

Anonymous said...

Hi Jobesh, thanks for sharing such a very useful information

Anonymous said...

I tried implementing same way, but instead of hard coding rows, I have populated rows programatically by calling some other service,
I have overridden below methods
create()
executeQueryForCollection() - In this I am calling getRowCount() to get value for 'rows'
- I am always getting '0' for getRowCount() .. Any idea why?

Jobinesh said...

try calling getEstimatedRowcount()

Anonymous said...

Thanks for reply,
I tried estimatedRowCount() , but still getting zero.
Thanks

Anonymous said...

Hi,
I have the following scenario.

1) I call a method in the App module.
2) The method fires a query on a VO say searchVo
3) I iterate through the result set and populate a transient Vo "SearchResultVO"
4) Use this transient VO to display the result as a table.

My problem is I am unable to sort the columns. The table goes blank "No data to display".
Thanks for any help

Anonymous said...

Hi Jobinesh,

when AM pooling is disabled (setting jvm startup parameter -Djbo.ampool.doampooling=false), the sorting stops working. I tried setting passivate state (including all transient values) to true in TransientViewObj, but still no luck. Do you know how to get around this issue?