[Catalyst] RFC: HTML::Widget / Ajax / Catalyst

A. Pagaltzis pagaltzis at gmx.de
Fri May 5 01:47:26 CEST 2006


Hi Sebastian,

* Sebastian Riedel <sri at oook.de> [2006-05-04 20:35]:
> 04.05.2006 17:13 Brandon Black:
> > I'd really like to see it also cover thigns like js-based
> > client-side form validation that is automatically generated
> > from the same rules as the server-side validation for the
> > same form, etc.
> 
> That will never work, there are always callback constraints and
> things like that.
> I'd prefer to use Ajax and validate server side using the
> original Perl constraints.

It can work, as has been pointed out. What you do is:

• For controls with validation callbacks, you generate
  self-sufficient Javascript to do the validation.

• For controls with callbacks or other custom stuff that cannot
  be translated to Javascript mechanically, you generate AJAX
  hooks. These hooks do not validate an individual field, they
  send the entire form to the server as if it was a regular POST,
  except that it’s marked as a validation-only request. The
  server then runs all the normal form validation, but stops
  processing the request after at that point, and sends back the
  result as something easily parsable, probably JSON, because XML
  is too much work to monkey with.

And well, that’s it. This honours DRY and keeps the user
experience pleasant.

Regards,
-- 
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;



More information about the Catalyst mailing list