Vgo Software

« ADF ConcurrentModificationException Issue Resolved | Main | NEOS on the news! »
Monday
Nov052012

ADF View Objects with Dynamic Where Clauses

While working on a recent modernization project I came across a scenario in which a View Object used by a page had a different where clause depending on one of the values passed in.  All in all, not too big of a deal, but because the where clause used a number of parameters and the parameters used changed along with the where clause it introduced some complications.  So to save you the trouble I thought I'd write about a couple of them here.

First of all, it is easy enough to to create a method in an Aplication Module implementation class that adjusts the where clause to what you need using the ViewObject.setWhereClause(String whereClause) method.  To set the parameters you need to use the ViewObject.setNamedWhereClauseParam(String paramName, Object paramValue) method.  What I found was that I had to have the parameters set at Bind Variables in the View Object and they must have their required property set to true, otherwise they are not really bind variables.  

What that means is that to execute the query, it must contain all of the bind variables even if they are not being used.  That means putting them in the where clause all the time.  To accomplish this for bind variables that were not used, I just put something like "and :par1 = null" and set the value to null using the above method.

This works fine except that since the bind variables are not in the original query definition another problem was encountered.  As soon as the task flow opened, the first thing it had to do was run the method I defined in the Application Module, unfortunately that did not happen.  Instead the first thing that happened was that the View Object executed and returned an error because the bind variables were not in the query.

Apparently in order for my method to work, I needed a page definition file that allowed my method to access my View Object's iterator.  Because this iterator was in the page definition file, ADF executed the query upfront even though nothing that used it was being called yet.  In order to fix this I set the refresh property of the iterator in the page defintion to "never".  This means that the iterator will not execute unless refresh() or execute() are called programattically on the View Object.  Of course this happens in the Application Module method that sets up the where clause after the where clause has been defined with the parameters in it.

That's it, simple enough once you realize what is happening, but a little frustrating before that light bulb goes on!

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (8)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    Response: indexing programs
    Very good Site, Maintain the good work. Thanks.
  • Response
    Java-Hair - Articles - ADF View Objects with Dynamic Where Clauses
  • Response
    blind boys of alabama sing 'nuclear' gospel Transit questions on the wa jordan 11 retro concord y to field sites helped to ready me and my jordan 11 concord 2014 partner for what we be looking at, to reflect on the implications of our mini field trip, and ...
  • Response
    Java-Hair - Articles - ADF View Objects with Dynamic Where Clauses
  • Response
    Response: hairstyle
    Java-Hair - Articles - ADF View Objects with Dynamic Where Clauses
  • Response
    Java-Hair - Articles - ADF View Objects with Dynamic Where Clauses
  • Response
    Java-Hair - Articles - ADF View Objects with Dynamic Where Clauses
  • Response

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>