Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: creating a Catalyst View component

by shenme (Priest)
on Feb 26, 2006 at 18:35 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found