I have a number of chained actions that use an end() method that generates a json response in a view.<div><br></div><div>Another developer added an action to support a POST, and at the end of the action they call $c->visit on a few actions to build up a response -- I assume to avoid making a few extra ajax requests. $c->visit does a full dispatch so auto and end methods are called for each visit, plus for the original action. But, because of the chained actions, $c->visit makes running the requests very simple.</div>
<div><br></div><div>Yes, normally the POST would be followed by a redirect, but this POST is a file upload in an iframe an a json response is desired. But, doing this partial re-dispatch has also come with GET requests.</div>
<div><br></div><div><br></div><div>Any tricks to do a $c->visit type of call but w/o doing a full dispatch, that is, without calling the auto and end actions?</div><div><br></div><div>I suppose I could do something like this, but it's not very pretty.</div>
<div><br></div><div><div> for my $action_name ( @action_names_to_run ) {</div><div> local $c->req->{method} = 'GET';</div><div> local $c->request->{arguments} = [];</div><div> local $c->request->{captures} = [ $item_id ];</div>
<div><br></div><div> my $action = $c->controller->action_for( $action_name );</div><div> $action = $c->dispatcher->expand_action($action);</div><div> local $c->{action} = $action;</div>
<div><br></div><div> $action->dispatch( $c );</div><div> }</div><div><br></div><br>-- <br>Bill Moseley<br><a href="mailto:moseley@hank.org">moseley@hank.org</a><br>
</div>