Tuesday, August 15, 2006

JSF Controls

Well we chose JSF because it provides and easy method for developing custom controls. I’m not sure what convoluted definition of ‘easy’ the JSF spec uses but I think there on crack. Having used C# custom and user controls JSF’s definition is way off.

First of all you can’t just create a control and edit it with a WYSIWYG editor. C# only provides this for user controls. Which are in essence a set of controls nested together with C$ backing code.

Now with C# custom controls you basically can just write HTML to a HTTP response. Any script kiddy will feel right at home doing this. Now for a JSF control? Well first you have to define a tag class Tag.java. Here you create the setters for the properties of the tag. Then you create .java which extends UI Component now you have to implement all the abstract methods and define the family, component name, and several other things. Now finally you can define the last class which implements another interface Render.java. This class tells JSF how the control gets rendered on the screen.

So were done right? Sadly no. Now you have to define a TLD for faces to read and make sure it’s in a jar on the class-path or in WEB-INF.

Oh wait! We forgot to add the render to the faces-config.xml. Ok so now it the moon, sun and stars are aligned your control should load.

See? Isn’t JSF so wonderful and simple! *barf*

No comments: