Tuesday, January 20, 2009

Decorator

Decorator filter lets you update pages on the fly. Filter lets you add dynamically (on the fly) some content to the serviced requests. More precisely filter adds content from the given file before, after or inside of the given HTML tag (e.g. before the body tag, or after the head tag etc.). For example lets us add a new style for the each div tag. We can create a file /styles/add_on.txt with the following content: style="color:red". Now with the Decorator filter we can do the following:

<filter>
  <filter-name>DecoratorFilter</filter-name>
  <filter-class>com.cj.decorator.DecoratorFilter</filter-class>
  <init-param>
    <param-name>data</param-name>
    <param-value>/styles/add_on.txt</param-value>
  </init-param>
  <init-param>
    <param-name>tag</param-name>
    <param-value>div</param-value>
  </init-param>
  <init-param>
    <param-name>place</param-name>
    <param-value>inside</param-value>
  </init-param>
</filter>

and as soon as we map this filter to our JSP files, filter will update div blocks on the fly.

P.S. check out other filters in our JSOS package. There are a lot of updates.

No comments: