Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: creating a Catalyst View component

by shenme (Priest)
on Feb 26, 2006 at 18:35 UTC ( #532906=note: print w/replies, xml ) Need Help??

in reply to creating a Catalyst View component

As rhesa mentioned, you don't do output directly from your view. Rather you give the output generated by your view back to the Catalyst. (In this way, Catalyst is like CGI::Appl and several other MVC frameworks)

While this interface seems cumbersome and adds a little overhead, it does allow for some nice capabilities, like centralized error processing, wrappers, or post-processing (think XSL transformations). I'm sure other people have really good examples of capabilities.

Anyway, you want to be looking in the documentation for how to use $c->response->body (the shorthand reference you'll often see is $c->res->body . If you look into other view code sources, you will that view actions can end with code like:

$c->response->body($output); return 1;
where previously generated output in $output is given to Catalyst and the view routine simply returns. You replace or add to the output body contents using the API. When you return from the view component, Catalyst (or other components in your application) may examine or modify the contents of the body. Then Catalyst will output the header, then the body.

You will also want to check out things like $c->response->status and $c->response->content_type to see how to interact with Catalyst to specify the other HTTP output data.

Replies are listed 'Best First'.
Re^2: creating a Catalyst View component
by holli (Abbot) on Feb 26, 2006 at 22:19 UTC
    Very well written and very helpful. Thank you.

    holli, /regexed monk/

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://532906]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2022-10-02 05:48 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (7 votes). Check out past polls.