myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvanma...@comcast.net (Gary VanMatre)
Subject Re: Custom ViewHandlers
Date Tue, 27 Mar 2007 02:18:48 GMT
>From: Simon Kitching <simon.kitching@rhe.co.nz> 
>
> 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. 
>

Trinidad also has an interesting pluggable view handler.  They call it an InternalView handler.
The basic idea is that there is a properties file that you register viewIds [1] that are associated
with internal views.  Next, you provide your custom implementation of the InternalView interface
[2].


[1] http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/resources/META-INF/org.apache.myfaces.trinidad.render.InternalView.properties?view=log
[2] http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/PageHandler.java?view=markup



Gary

> Regards, 
> 
> Simon 
> 
Mime
View raw message