Skip to main content

Explicitly enabling in-memory sorting for a view object

Sharing a tip that I learned while debugging an issue ;)
When you try to sort a UI component such as af:table bound to a view object, framework by default fire SQL ORDER BY clause if the selected column is not a transient one, otherwise framework will go for an in-memory sort by calling setSortCriteria(...) on the ViewObject.

You can override this default behavior by setting a custom property on the ViewObject. This make sense if your view object is a programmatic  or transient view object or if the view object contains uncommitted rows.To do this, you need to set a property named PROP_ALWAYS_USE_SORT to true (available in release). When PROP_ALWAYS_USE_SORT is 'true', framework will always go for in-memory sorting.

empVO.setProperty(ViewObject.PROP_ALWAYS_USE_SORT, "true");

Warning: Note that when you enable in-memory sorting, framework will fetch all the records from the DB before performing the sort. So it makes sense only if you have limited number of rows.


Anonymous said…
hi Jobinesh,

May be this is what I was exactly looking for. But my ViewObject doesnot have that 'PROP_ALWAYS_USE_SORT' static variable. I am using Jdev

In which version it is supported.

If you can , please see my forum thread. I need solution for this

Jobinesh said…
This property is available in
Anonymous said…
Thanks for the info. I guess I am looking for a way to do this declaratively from ADF Faces. From what I can gather from section 27.5, I see a way to sort in memory if I am writing the code to interact with the view object. But I am trying to use af:table and data binding and not write the low-level code. Since the rich-client af:table has a sorting capability built-in, I want to have a way to tell the framework to sort in memory. To get more info please visit
BradW said…
You can also use the view to set the query mode.


Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

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…