ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Web DbForms
Pages: 1, 2, 3, 4, 5

Sorting, Searching and Filtering


Sorting is an important, even essential, feature for many database applications. For example, if you would like to give the user the ability to sort the virtual agency's services by ID, you can use the following DbForms sort tag:

Listing 9. Instantiating a sort tag

<db:sort fieldName="id" />


Just like sorting, filtering of data rows is an important functional requirement for many database applications. In its simplest case, the "filter" is nothing more than a part of the WHERE clause of the SQL SELECT statement used to retrieve the rows.

The filter criteria may be passed to the filter attribute of the DbForm tag:

Listing 10. Filtering

Comment on this articleDo you use DbForms? What are your thoughts about such a productive tool?
Post your comments

<db:dbform tableName="employee" maxRows="*" followUp="/employees.jsp" autoUpdate="false" filter="deptno=101 AND salery>3000">
</db: dbform>


Searching is another "must-have" functionality for a database application framework like DbForms.

DbForms allows you to create search forms very quickly. The number of fields to be searched, the kind of input widgets (textfield, textArea, select box, etc.), the kind of search algorithm to use, and the boolean combination of matches of search criteria are completely flexible.

All you have to do is:

  • Decide which fields you want to make searchable
  • Decide if you want the user to choose the criteria-combination mode himself/herself or if you want to use a (hidden) default
  • Decide if you want the user to choose the kind of search algorithm to be used himself/herself or if you want to use a (hidden) default

Figure 7 shows a fully functional search panel. It is included in the example that comes with the DbForms distribution. You may also test it on the running live samples at the DbForms Website.

The search panel.
Figure 7. Example for a search panel.

Implicit Scriping Variables

DbForms tags like <db:dbform> and <db:body> make some information available to the embedded JSP code, where the values are accessible as simple scripting variables.

The mechansim used for passing these values over is called "Tag Extra Info" and is part of the Java Server Pages specification 1.1.

Two useful scripting variables are listed in Table 1:

Table 1. Two useful DbForms scripting variables

Name Type Description
currentRow java.util.Hashtable

Contains the field values of the current row. This construct is similar to "associated Arrays" used in many Perl/PHP modules.

Example: String email = (String) currentRow.get("email");

Scope: inside the respective <body> element

position java.lang.String

Contains the encoded key-fieldvalues of the current row.

Scope: inside the respective <body> element

These (and many other) scripting variables can be used by a JSP developer to add advanced functionality to her/his DbForms-driven JSP page.

Pages: 1, 2, 3, 4, 5

Next Pagearrow