[Catalyst] Using Jquery UI Autocomplete widget with Catalyst::View::JSON

Alexander Hartmaier alexander.hartmaier at t-systems.at
Mon Apr 26 16:41:02 GMT 2010


HRI will return prefetched rels too, get_columns won't.

--
Best regards, Alex


Am Montag, den 26.04.2010, 17:23 +0200 schrieb Ben van Staveren:
> Used it but at the same time, doing my $hashref =
> { $row->get_columns } got me more or less the same effect for a lot
> less hassle :)
>
> I actually do this for most my DB objects that get serialised to JSON,
> quite simple case of $c->stash->{json} = [ map { $_->get_columns }
> $rs->all ];
>
> In a similar vein, I haven't yet really seen/heard any sort of "best
> practices" when it comes to Catalyst and JSON, so maybe I'm going
> about it all wrong but eh :)
>
> Lee Aylward wrote:
> > On Mon, 26 Apr 2010 16:33:31 +0700
> > Ben van Staveren <benvanstaveren at gmail.com> wrote:
> >
> >
> > > Probably not the most pretty one but:
> > >
> > > Given you have a resultset obtained with, say,
> > >
> > > my $result_set = $c->model('DB::Somedata')->search_rs({...}, {...});
> > >
> > > $c->stash->{json} = [
> > >   map { id => $_->id, label => $_->name } ($result_set->all)
> > >   ];
> > >
> > > Or a bit more verbose:
> > >
> > > foreach my $result ($result_set->all) {
> > >   push(@{$c->stash->{json}}, { id => $result->id, label =>
> > > $result->name }); }
> > >
> > >    `
> > >
> > >
> >
> > I've also had good luck using DBIx::Class::RsultClass::HashRefInflator
> > in the past. It doesn't give you quite as much control, but it may be
> > enough for your needs.
> >
> > http://search.cpan.org/~frew/DBIx-Class/lib/DBIx/Class/ResultClass/HashRefInflator.pm
> >
> >
>
> --
> Ben van Staveren
> phone: +62 81 70777529
> email: benvanstaveren at gmail.com


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the Catalyst mailing list