Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:21:09 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

November 2006
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Oct   Dec

Get Firefox!

Tuesday, November 21, 2006

I was asked a question today, "How does the (Clear) button on the SRDemo sample application's SRSearch page clear the search criteria? I can't find the code that's doing it."

It's a great question since there effectively is no code required to accomplish it, but the declarative technique employed to achieve the result may not just immediately jump out at you. I'll try to simmer it down to its essence. First, recall that the SRSearch page is a search form implemented using the basic technique that I visually demonstrate in the Part 1: Web-Style Search Form screencast over on my screencasts page. This means that it has two iterator bindings bound to the same view object, one which is declaratively forced to always stay in "find mode". Section 10.5.3 How to Use Find Mode to Implement Query-by-Example in the ADF Developer's Guide for Forms/4GL Developers explains how an iterator binding in find mode points to a row set of query-by-example "view criteria" rows instead of the rowset of retrieved data. Each view criteria row represents a set of query criteria for selected attributes.

In the page definition for the SRSearch page, there is an action binding named "Delete" that is bound to the SearchServiceRequestsIterator iterator binding, which is the one that is always forced to stay in find mode. That means that when this action binding is triggered, it deletes the view criteria row in the row set of query criteria, thus removing/forgetting any current seach criteria the user had supplied before.

The button labeled "(Clear)" in the page is bound declaratively to this "Delete" action, so clicking the (Clear) button deletes the view criteria row in the row set of query-by-example criteria for the iterator in find mode.

Then, an invokeAction executable named "insertBlankViewCriteriaRowIfThereAreNone" triggers a corresponding "Create" action binding (also related to the iterator binding that stays in find mode). This serves to create a "fresh" new view criteria row used to remember the end-user's next query criteria. That invoke action has a RefreshCondition EL expression set to:

${bindings.SearchServiceRequestsIterator.findMode 
and bindings.SearchServiceRequestsIterator.estimatedRowCount == 0}

This causes the invokeAction to "fire" only when the named iterator is in find mode and currently has zero rows of view criteria query-by-example rows. It also has a Refresh property with value "renderModel" so that it only is considered for firing during the render phase of the ADF page request lifecycle.

So the net result is that clicking on the (Clear) button...

  • Triggers the firing of the "Delete" action binding which removes the view criteria row that was holding the previous search criteria
  • Then, during the render phase of that same page request, the invokeAction creates a fresh new view criteria row by conditionally invoking the "Create" action binding

You can reference section 10.5.5 How to Use Refresh Correctly for InvokeAction and Iterator Bindings in the Dev Guide for more information about how to correctly configure the Refresh and RefreshCondition properties of an invokeAction.

 


11:44:36 PM    



© Copyright 2008 Steve Muench.