[Catalyst] RFC: HTML::Widget::JavaScript

Nilson Santos Figueiredo Junior acid06 at gmail.com
Mon Mar 13 18:20:44 CET 2006


I'm not usually very fond of sites where all the validation is *only*
done at the server.
This provides, IMO, a lousy user experience.

However, I'm also sane enough to acknowledge that some sites out there
that leave it to the client to do all validation and verification were
obviously made by lousy coders. But client-side validation *does*
provide a more seamless user experience.

HTML::Widget provides a well-defined constraint system for each of the
user-editable fields, so I thought it wouldn't be that hard to make it
also emit some JavaScript constraint checking code. And thus came
HTML::Widget::JavaScript.

Right now it's pretty basic. It implements most of the existing
constraints in JavaScript but the error handling is still very crude
and non-customizable (when the form is submitted, if some constraint
fails an alert box pops up with the constraint's "message" attribute).
But it suited my temporary needs. And it's done in such a way that if
the client has JavaScript disabled or something like that, it just
doesn't get into the user's way and rely on the server to handle
validation (as it would).

I decided that although the JavaScript code generation seems a bit
hackish (I actually don't know if it really is, but it sure seems to
be), it was CPAN worthy. But I am now asking your opinions about it
and/or how could I improve it. Or if this idea is completely rubbish
and I should ask the CPAN indexer to delete them immediately.

You can see it at:
http://search.cpan.org/~nilsonsfj/HTML-Widget-JavaScript-0.01/

There's also a companion Catalyst plugin at:
http://search.cpan.org/~nilsonsfj/Catalyst-Plugin-HTML-Widget-JavaScript-0.01/
(This plugin shouldn't need further updates as the main module evolves)

When all of this gets into a reasonable "trustable" level, it could
maybe get into the main HTML::Widget distribution.

So... any comments?

-Nilson Santos F. Jr.



More information about the Catalyst mailing list