Skip to main content

Displaying an empty table !

The title sounds silly, right? Whats the big deal in this? Yes you are right, this post discusses a very simple 'tip'. The use case requirement here is a pretty simple one where a table in a data capture page should be displayed empty on some conditions. Annoyingly, a table created by dragging and dropping a ViewObject on a page always display data. Hmm...this is very much expected, as and when the table renders, table model will try to get data though the binding by executing the ViewObject.
How to prevent this execution? Let me ask you a counter question, How does a search screen with result table displays empty result table initially?
A simple us case triggers lots of questions :) The answer for the above question end up in search binding's 'AutoQuery-or-ClearRowSet'. This is explained in one of my previous post.

Clearing RowSet

Lets us focus on 'ClearRowSet' behavior in this post. ClearRowSet in turn calls ViewObjectImpl::executeEmptyRowSet(). This method actually mark the ViewObject as executed and present the caller with empty row set , without actually triggering a database query. If you really want to know more about this method, please check out this post What Does executeEmptyRowSet() Do? from Steve Muench

Oh, cool...Can we use this strategy for the above use case as well?
Answer is YES.
Define an ApplicationModule method that calls ViewObjectImpl::executeEmptyRowSet(), drag and drop this as method call activity on you navigation definition( adfc-config.xml / your-task-flow-definition.xml) and then define a control flow connecting between caller and callee views(callee is supposed to display the empty table) with the above defined method call activity as an intermediate step. Control flow case looks like as shown below

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


Baig said…
Thanks for the post.

i guess same could be achieve using Iterator Refresh condition in binding section but this is more visual way to do this.

Keep posting,
Zeeshan Baig
Jobinesh said…
You are right, that may work for certain set of use cases. But in most of the cases the requirement could be not just displaying an empty table, but enable the user to key in new set of records as well. There the approach based on 'Iterator Refresh Condition' may not be feasible and it may have its own side effects.

On a related note, there are certain use cases where developers need to use 'InitialQueryOverridden' for search binding. I've seen some use cases where pre-execution of query is not possible for each and every alternate flows. In this cases ViewOnjectImpl::exceuteEmptyRowset() will help developers to prevent the unwanted query execution while displaying the Query screen.
Baig said…
Thanks for more info.

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…

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 !!!