[NFJS Denver] Howard Lewis Ship and Creating Tapestry Components
Tapestry - "we try to make the simplest approach the correct approach." I haven't been blogging much of this session b/c I'm just sitting back and
soaking it up. It's a good session and Howard is a good speaker. I'm learning a lot about Tapestry and it's philosophy about web development.
I especially like the line-precise error reporting - it's something that all frameworks need to do better.
Tapestry looks very cool. You basically
write an abstract Java class that has abstract methods for properties you define in an XML file. Tapestry them implements this class and its abstract
methods. The class that Howard wrote to handle a login form is very simple - it's only about 7 lines long - and 4 of those are abstract methods!
The HTML form is cool too - not much of the HTML
has changed since it was bare-bones HTML. He's merely added some a few "jcwid" and "listener" attributes to some of the elements.
Tapestry is a large system of subsystems, all implemented behind interfaces. It ships with its default behavior (i.e. page/template pooling), but you can
(supposedly) easily change this behavior or implement custom classes. Internationalization is a first-class citizen in Tapestry - no surprise here since it is
in most MVC frameworks. Tapestry 3.1 will embed Hivemind at its core and will provide much easier integration with tools like Hibernate and Spring.
Tapestry's "Validation Subsystem" looks very rich - providing both client side and server side validation. It uses Field decorations to highlight both labels
and fields when validation fails. By default, it promotes using CSS to change colors, backgrounds, etc. There are a couple of Helper Beans for validation:
the Validation Delegate and the Validator. It's pretty neat that you can bind a label to a field in XML. Since HTML already allows binding
<label>'s to form elements - you'd think that Tapestry could harness this by parsing the template. I suppose it's just easier to require the
XML binding - then you don't have to worry about the user writing invalid HTML.
Howard is trying something new in this presentation - real-time coding. I use this in my presentations and it works pretty good. He's having some serious issues b/c he can't mirror his laptop's monitor with the projector. This obviously makes it difficult to code since the slide show is his monitor. I try to use pre-canned code (i.e. IDEA Live Templates) so there's less chance of fat fingering things. I also use a Mac - on which mirroring works great.
The "Page" object is pretty cool in that it contains a bunch of lifecyle methods you can override. Most frameworks don't have lifecycle methods. I guess
Spring's SimpleFormController does with onSubmit, onBind. Lifecycle methods are a Good Thing IMO. The formSubmit()
method is always called,
regardless of validation errors. Therefore, you have to get the IValidationDelegate and check if it has errors before continuing. I wonder what the logic
behind this is? Most frameworks seem to support automagical validation - with no further work required by the programmer. I guess it's kinda cool b/c you
can continue with validation errors if you want to. Choice is always a good thing.
Howard just showed us a client-side validation example. The wicked cool thing is that the client-side script is configured in a .page file rather than in the
HTML template. Most frameworks I've seen (that support client-side validation) require you put something into your template. This was a good
talk, I'm definitely interested in Tapestry and excited to start learning it in the next couple of months.
I'll be interested to read how you get on though!
Posted by Gwyn Evans on May 26, 2004 at 10:33 AM MDT #