FAQ
Hey all,

I got an issue with creating a JSON view. So here is my setup

I have my catalyst app named scorer.
I have a controller named rules
I am using TT for views and everything is working fine
I wanted to add ajax so I added a method in my controller to get some
values for a drop down
I am using mochikit for the js scripting with the js file in my static
directory
I added a JSON view to my app but when I forward from my method I get
this error

* Couldn't render template "file error - rules/get_value_operators: not
found"

My method is simple it looks like this

sub get_value_operators : Local
{
my ($self, $c, $match_type_id) = @_;

$c->stash->{json} = $c->model('scorerDB::value_operator')->search
(
{
'match_type_id' => $match_type_id,
}
);

$c->forward('scorer::View::JSON');
}


My understanding may be wrong but the json view should create the
headers and return the result itself right? I shouldn't need to create a
template file on disk for a json view or so I assume. The only thing I
can think of is that for some reason it is still being sent to my TT
view.

Any advice or tips is appreciated.

Thanks,
------------------------------------------
Ali Mesdaq
Security Researcher II
Websense Security Labs
http://www.WebsenseSecurityLabs.com
------------------------------------------

Search Discussions

  • Tatsuhiko Miyagawa at Aug 9, 2007 at 2:07 am

    On 8/8/07, Mesdaq, Ali wrote:
    $c->forward('scorer::View::JSON');
    }


    My understanding may be wrong but the json view should create the
    headers and return the result itself right? I shouldn't need to create a
    template file on disk for a json view or so I assume. The only thing I
    can think of is that for some reason it is still being sent to my TT
    view.
    I encountered with this probelm a few week ago with my pet project.
    I've never used View::JSON with my real project.

    Try this instead:

    $c->stash->{current_view} = 'JSON';

    The View::JSON doc is kinda obsolete and I guess incompatible with the
    current RenderView default action.

    If there's a better way to do this, let me know and I'll update the doc.

    --
    Tatsuhiko Miyagawa
  • Hartmaier Alexander at Aug 9, 2007 at 3:16 pm
    I'll just do this at the end of my controller method:
    $c->forward('My::App::View::JSON');

    - Alex
    -----Original Message-----
    From: Tatsuhiko Miyagawa
    Sent: Thursday, August 09, 2007 3:07 AM
    To: The elegant MVC web framework
    Subject: Re: [Catalyst] Issue with JSON view
    On 8/8/07, Mesdaq, Ali wrote:
    $c->forward('scorer::View::JSON');
    }


    My understanding may be wrong but the json view should create the
    headers and return the result itself right? I shouldn't need to create a
    template file on disk for a json view or so I assume. The only thing I
    can think of is that for some reason it is still being sent to my TT
    view.
    I encountered with this probelm a few week ago with my pet project.
    I've never used View::JSON with my real project.

    Try this instead:

    $c->stash->{current_view} = 'JSON';

    The View::JSON doc is kinda obsolete and I guess incompatible with the
    current RenderView default action.

    If there's a better way to do this, let me know and I'll update the
    doc.

    --
    Tatsuhiko Miyagawa

    _______________________________________________
    List: Catalyst@lists.rawmode.org
    Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-
    archive.com/catalyst@lists.rawmode.org/
    Dev site: http://dev.catalyst.perl.org/
    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: smime.p7s
    Type: application/x-pkcs7-signature
    Size: 5611 bytes
    Desc: not available
    Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070809/bb99b936/smime.bin

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedAug 9, '07 at 1:50a
activeAug 9, '07 at 3:16p
posts3
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase