Brad Smith wrote:
I was wondering how a custom ViewHandler is managed in MyFaces. A custom
view handler seems to be an elegant solution to a problem I am dealing
with, yet I will also be using Facelets.
Facelets uses a decorator pattern in it's ViewHandler, that is the
constructor takes a base ViewHandler as the only argument.
I am wondering how to easily chain ViewHandlers so that my custom
ViewHandler can decorate the FaceletViewHander (or other ViewHandler
such as the default ViewHandler for MyFaces).

It's very simple. I did it just a week or so ago; it was an attempt at fixing something that turned out easier in another way so I've deleted that code however here's what I remember:

First write a subclass of ViewHandler that takes another ViewHandler as a parameter to the constructor. This constructor will be called passing the "preceding" viewhandler instance so you can chain calls to it from your custom class.

Second, add the following to your faces config file:
  <application>
    <view-handler>example.MyViewHandler</view-handler>
  </application>

All done.

Regards,

Simon

Reply via email to