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

Carl Franks fireartist at gmail.com
Thu May 4 17:01:42 CEST 2006


I'd like new ajax-enabled H::W elements.

I've started playing with dojo, and think it'll be the best ajax toolkit to use.
It currently already has dojo "widgets" for
Auto-Complete (using either an input/textfield or a select element),
an Inline-Edit box (a paragraph or header which turns into a form
input when clicked),
a graphical Date-Picker,
a graphical Time-Picker,
an "Editor" element (providing bold, italic buttons, etc).

I'm not quite sure how best to integrate dojo, and also how to get it
working as easily as possible with catalyst (and others :).
The dojo distribution itself contains a couple hundred files, which
can be loaded on demand.
If you use the "ajax" flavour, then all necessary functions are
"baked" into the main dojo.js file, and only the individual widgets
need be loaded on demand.

I've submitted a couple of patches to C::P::Static::Simple this week,
specifically to help catalyst support dojo.
http://www.gossamer-threads.com/lists/catalyst/users/7182
http://www.gossamer-threads.com/lists/catalyst/users/7187

I'm envisioning creating a C::Plugin::Dojo package. This would create
a Helper package which would just dump the dojo folder in, say,
root/static/dojo.
It'll give you the option of whether to use the ajax, event, io,
widget or kitchen sink distro.
And the Plugin package would provide methods for use in template
files, something like:

[% c.dojo_base_tag %]
# outputs
<script type="text/javascript" src="static/dojo/dojo.js"></script>

[% c.dojo_require_tag('dojo.widget.html.DatePicker') %]
# outputs
<script type="text/javascript">
dojo.require("dojo.widget.html.DatePicker");
</script>

At the most basic, the way the H::W elements could work is:
You first need to add the [% c.dojo_base_tag %] to the head of your
template file.
When the element is rendered, it'll automatically add appropriate
script tags to load the appropriate dojo widget.

Now, the part I haven't experimented with yet, is getting the elements
to use id's and classes consistent with the existing H::W elements.
To do this, I think we may need to create our own dojo widgets, which
inherit the ones provided with dojo.
This means we'll need to be able to load js, css, gif and png files
from outside of the static/dojo folder.
How best to do this?
Should we have the content of these files available from methods in
the Element::*.pm files?
And should C::P::Dojo then also intercept the appropriate url's,
returning the data from those methods?

And, of course, the path to the dojo folder, and the path to the extra
widget files would have to be user configurable.

Okay, I obviously don't have a fully formed idea of how to do this -
which is why it's an RFC.
Does any of this so far make sense? Am I talking crap?
As always, comments please!

Carl



More information about the Catalyst mailing list