12.2. Filter Tag

There now exist three main ways to filter information

  1. Filter tag (from 1.1.4pr1)

    The filter tag can be thought of as the next generation filtering method and can effectively replace the following filter and whereClause attributes, as well as providing an improved alternative to variable searchFields.

    It has these advantages:

    • Allows for more complex sql conditions than the filter attribute allows

    • Navigation works with both classic and dataList navigation sytems (navigation with a whereClause only works with dataList).

    • Simplifies searching.

  2. filter attribute in dbforms tag

  3. whereClause attribute in dbforms tag

12.2.1. The Filter Tag in Use

The filter tag allows for easy use of user's input as well as fixed sql conditions.

It will render a select box for the user to choose which filter they would like to use. Once they have chosen, it will (if desired) render a way to input condition values. Finally buttons to "set" or "unset" the filter will be generated. This can be seen twice in the following example (bookstore/tests/testAuthorBooksSubFormWithFilter.jsp).

In the first filter [for the parent form -- here placed in its footer], the user chooses from a select box populated with data obtained via a queryData tag. Here it is used to select which author is to be viewed.

<db:filter>

  <db:filterCondition label="author is">
    NAME = ?
    <db:filterValue type="select">
      <db:queryData name="q1" query="select distinct name as n1, name as n2 from author where AUTHOR_ID < 100 order by name"/>
    </db:filterValue>
  </db:filterCondition>
  
  ...(other filterConditions can be included for the user to select from)...
</db:filter>
      

In the second filter [for the subform -- here placed in its the header], the user inputs filter critera into a text box. Here it is used to select titles from the author chosen in the first filter.

<db:filter>
  <db:filterCondition label="title like">
    TITLE LIKE %?%
     <db:filterValue/>
  </db:filterCondition>
  
  ...(other filterConditions can be included for the user to select from)...
</db:filter>      
      

See the filter tag for more information and usage details.