15.6 Filters

Java Servlet Programming, 2nd Edition > 15. WebMacro > 15.6 Filters

 
< BACKCONTINUE >

15.6 Filters

At the time of this writing, WebMacro has just opened up its development process to a wider audience and moved from the relatively restrictive GPL license to the less restrictive Apache-style license. As a result of the increased developer resources, many interesting and useful enhancements are now in the works.

The most substantial enhancement involves a pluggable filter mechanism. The idea is for a variable to go through a filter when output, with the filter controlling how the variable is displayed. Standard filters are likely to perform:

HTML escaping

Filter a user-entered comment field to prohibit special characters from accidentally or maliciously causing problems.

Localization

Filter a date through some localized display logic.

URL rewriting

Filter a URL to add the jsessionid session-tracking value.

Display of null values

Filter the display of null variables to output an error message or silently ignore the variable.

15.6.1 Custom Filters

Custom filters hold particular promise. For example, a customer variable could be filtered through a customer template designed to render the variable and its properties based on an external template file. The customer template might even filter the customer's address through an external address template. This allows easy reuse and customization of display logic. Filters may support being chained as well. That would allow, for example, a variable to be both localized and escaped, with a predetermined output value should the variable be null.

The possible uses for filters are still purely in people's imaginations. It will be interesting to see what uses for WebMacro filters actually become popular.


Last updated on 3/20/2003
Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

< BACKCONTINUE >


Java servlet programming
Java Servlet Programming (Java Series)
ISBN: 0596000405
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net