Skip to main content

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.


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
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.
Anonymous said…
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?
Raúl García said…
Hello Jobinesh, a need I have a ViewObject that has many based atrributtes and one transient atrributte, but I just need to Sort that Vo having that transient atrributte.
It could be possible????
Sorry for my english!!
Raúl García said…
This comment has been removed by the author.
Can you please see if the following post helps:

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…