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; 8:12:22 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

April 2003
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      
Mar   May

Get Firefox!

Friday, April 25, 2003

"How can I use a view object in forward only mode, and still detect if any rows were retrieved, without already iterating to the first row?"

When a view object is used in forward only mode, you can only iterate forward through the rows. Often, when building web applications it's useful to display something different in your page in the case when your query returns zero rows. For example, you might want to display a message like "Your search found no items..." instead of showing an HTML table with headers and no rows in the table. After calling executeQuery() on your view object, but before iterating through its resulting rowset, you can call the hasNext() method on the view object to detect whether there are any rows to iterate through without actually advancing to the first one. If hasNext() returns false, then you can conditionally display your nicer message. If you are building your application in a clean Model/View/Controller style, then this call to hasNext() on your datasource would be done in your controller code, and you would set some request-scope attribute that your view layer can use to detect for existence in order to conditionally display the "No items found" message. This latter approach is the technique that the BC4J Toy Store Demo application uses when showing the results of the users query through the store items.


11:47:11 PM    



© Copyright 2008 Steve Muench.