[Catalyst] HTML::Dojo

Jonathan Rockway jon at jrock.us
Mon Nov 12 18:51:04 GMT 2007

On Mon, 2007-11-12 at 10:44 -0800, Will Smith wrote:
> Please show me a simple example such as auto complete or chained
> select fields.

That's too much work.  How about googling "dojo autocomplete", and
reading an article like this:


To make that work with Catalyst, just replace the java:

   public String toJSONString() throws JSONException {
    JSONObject jsonObj = new JSONObject();
    jsonObj.put("bookId", new Integer(this.bookId));
    jsonObj.put("title", this.title);
    jsonObj.put("isbn", this.isbn);
    jsonObj.put("author", this.author);
    return jsonObj.toString();

With Perl:

   sub search_for_book :Local {
      my ($self, $c, $search_term) = @_;
      my @results = $c->model('Books')->search_for_completion_of($search_term);
      $c->stash->{json} = { results => \@results };
      # or whatever

Catalyst rarely cares what you use for javascript.  You send the
javascript code data, the javascript does its thing, and perhaps the
javascript requests some more data.  The hard part is javascript, so
that's what you need to learn first.

Jonathan Rockway

More information about the Catalyst mailing list