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]

Comments

  1. Hi,
    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
    http://baigsorcl.blogspot.com/

    ReplyDelete
  2. Baig
    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.

    ReplyDelete

Post a Comment