[Catalyst] "internal" redirect?

Bill Moseley moseley at hank.org
Fri Nov 11 15:53:19 CET 2005


Still fixated...

Is there a way, other than an http redirect, to forward to another
action and have it seem like that was the original action that
matched?  Sort of an internal redirect?


if you have a "list" action that takes parameters:

    sub list : Local {
        my ( $self, $c, $limit ) = @_;

Then in a template you could use uri_for:

    <a href="[% uri_for('blue') %]">Limit list to blue items</a>
    # /foo/bar/list/blue

That works because it's based on $c->req->match.



But that also breaks if you also have an "edit" action that does this:

    sub edit : Local {
        my ( $self, $c, $id ) = @_;

        unless ( $id =~ /^\d+$/ ) {
            $c->stash->{message} = 'Sorry, id must be numeric';
            return $c->forward('list');
        }



Then when the list is displayed as above you get the wrong link:

    <a href="[% uri_for('blue') %]">Limit list to blue items</a>
    # /foo/bar/edit/blue instead of /foo/bar/list/blue


-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list