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

Search blog with Google:
 

Search BC4J JavaDoc:
 

January 2004
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 31
Dec   Feb

Get Firefox!

Friday, January 16, 2004

I'll be giving a presentation on JDeveloper 10g and ADF at the OOP 2004 Conference in Munich on Thursday, January 22nd, 2004. If you're planning to be there, come by and say hi.

Despite the fact that my great grandfather emigrated to America from Leipzig, Germany my dad never learned german (growing up in Minnesota and California), so neither did I unfortunately. I'm not sure where he got it, but my father was able to obtain a copy of the handwritten April 1930 census of Saint Paul city in Minnesota that shows that my great grandfather Herman was a tram driver, and supported his family of three kids, a wife, and his parents (my great, great grandparents) on that income. It shows they were all born in germany, and that my great- and great-great- grandparents spoke German as their native language. Fun stuff...


11:38:07 AM    



Terje from Norway writes in to ask, "I have a jsp web page showing an ordinary html-table with rows from a view object. One of the columns is postal code. I want to make a simple textfield and a submit button on the page that makes it possible to filter the table to show only rows with a user-entered postal-code. How is this done in JDeveloper 10g?"

As you might expect, doing any kind of filtering of query results in a database application boils down to getting an appropriate WHERE clause added to the SQL SELECT statement being performed to populate your display. I've prepared a SimpleFilteredQueryExample which illustrates how you can approach doing this in JDeveloper 10g when using ADF and JSP. 

To run the demo, you'll need the JDeveloper 10g preview release (9.0.5.0 build 1375)

After opening the SimpleFilteredQueryExample.jws workspace, and making sure you have a database connection named scott defined which points to a SCOTT/TIGER account you have in your environment:

  1. Expand the ViewController project, the Web Content folder, and the WEB-INF folder under that to click on the struts-config.xml file.
  2. Select the /employeesDataAction action in the structure pane (under "Action Mappings"), and select "Run" from the right-mouse menu to run this struts action.

Your default browser should appear and you'll see a form showing EMP table records 3 at a time. You can click (Next Set) and (Previous Set) buttons to page back and forth through the records.

If you type in a value like "10" into the "Filter" text box, then click on (Filter), you will filter the data to only show employees in that department. You then can page through the results of only that filtered set, if you want.

To remove the filter, click on the (Filter) button with no value in the text field.

Study the code of the demo.view.EmployeesDataAction so see how the filtering works. The comments in there explain what's going on. I've provided two alternative implementations of the code to do the filtering. One method named setupModelForPageRightHereInTheAction() illustrates how to do the filtering right in the Struts action, although that's not the most encapsulated way to accomplish the job. The alternative method setupModelForPageMoreEncapsulated() shows how you can encapsulate the logic that manipulates the details of your view object components into your ADF view objects and application module components. Then, the Struts action simple invokes custom service methods on the application module's custom service interface (named demo.model.common.MyModule in this example for my demo.model.MyModule application module component).

We also support a more generic Query by Example capability on view objects if your filtering requires allowing the end-user to pick and choose to filter on a user-defined combination of query critieria for the fields. See the JavaDoc for our oracle.jbo.ViewCriteria object, or my BC4J Coding Techniques example for some pointers on using it.

 


10:55:25 AM    


© Copyright 2008 Steve Muench.