That was the bit the did the trick.  I guess I didn't follow the documentation 
chain up high enough (I stopped at catalyst::component).  However one tricky 
part, if the action you name is part of a chain you need to make sure you 
submit the captures arrayref, otherwise $c->uri_for doesn't return anything.  
So for my example you could do:

my $view_action_link = $c->uri_for( $c->controller->action_for('view'), 
$c->request->captures );                    
$c->response->redirect( $view_action_link );

And this does exactly what I was looking for!  Thanks!

Just another note, you can skip passing the controller method a name if the 
action you are looking for is in the same package, which makes this even more 
generic.

This really helps to make your code more generic and simplified.  I just showed 
this to a group of consultants I'm working with on a cgi based application and 
I got them all drooling with envy :)

--john

----- Original Message ----
From: Bogdan Lucaciu <[EMAIL PROTECTED]>
To: John Napiorkowski <[EMAIL PROTECTED]>; The elegant MVC web framework 
<[email protected]>
Sent: Thursday, August 31, 2006 12:13:40 PM
Subject: Re: [Catalyst] Generate a URL for a given action

On Thu, 2006-08-31 at 08:28 -0700, John Napiorkowski wrote:
> because I already have the title in the database resultset and I know
> right now this controller is rooted to the start of the web server.
> What I would really like to know is if there is a programmatic way to
> get this stuff.  I know I can get the capture string via:
> $c->request->captures->[$level].  Ideally I wouldn't have to hard code
> so much controller specific stuff here.
> 

try
$c->uri_for($c->controller('Foo::Bar')->action_for('action_name'));

(action_for documented in Catalyst::Base)

-- 
Bogdan Lucaciu <[EMAIL PROTECTED]>





_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to