This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

--Data Filtering

Documents for the development of and with JVx.

--Data Filtering

Postby Development@SIB » Wed Sep 15, 2010 10:36 pm



This article is outdated - please use our new system at

https://doc.sibvisions.com




Displaying Data from a Database Table is a basic requirement for database applications. Restricting the data volume is another requirement. This can be done on the client side as well as at the database.

At the client, data is filtered in the main memory, which, however, requires that all data is transferred from the server/database to the client. This limits communication and should not be an issue for small data volume. However, it should be noted that data has to be updated manually!

Filtering at the database is the default setting and is usually the better choice. Here, the sorting conditions are included in the SQL command and the data volume is therefore limited by the database. Only the limited data is provided to the client and due to load-on-demand only the required amount is transferred. In addition, the transferred data is always current.


Example

Our application manages contact information (people, addresses, etc.). One of our forms has a field in which a search can be entered. A button is available to start a wildcard search by first name, last name, street address, or city.

The following client action achieves the desired filtering:

Code: Select all
/**
 * Searches the contacts with the search text.
 *
 * @throws ModelException if the search fails
 */
public void doFilter() throws ModelException
{
   String sText = (String)drSearch.getValue("SEARCH");

   if (sText == null)
   {
      //reset the filter: show all rows
      rdbContacts.setFilter(null);
   }
   else
   {
      //set the filter: show only found rows
      ICondition filter = new LikeIgnoreCase("FIRSTNAME", "*" + sText + "*").or(
                     new LikeIgnoreCase("LASTNAME", "*" + sText + "*").or(
                     new LikeIgnoreCase("STREET", "*" + sText + "*").or(
                     new LikeIgnoreCase("TOWN", "*" + sText + "*"))));
      rdbContacts.setFilter(filter);
   }
}

The filter or condition is applied to a RemoteDataBook and is constructed just as it would in SQL. The search is based on our condition for the appearance of the entered text, either first name, last name, the street or the city.

For sorting at the client, the RemoteDataBook would have to be configured as follows:

Code: Select all
rdbContacts.setMemFilter(true);
User avatar
Development@SIB
 
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation