I have an action in one controller that needs some db records stashed to render a table.
I have an action in a second controller that fills a very similar table, and so the data in its own stash is the same as I need for the first one.
Without duplicating a bunch of code in both controllers, is there a way to use one action to fill the stash of the other?
EDIT: In response to code request (somewhat simplified, but should get the gist across):
In Contoller::ShoppingCart
sub data : Chained('base') PathPart('') CaptureArgs(0) {
my ( $self, $c ) = @_;
my $query = DBRESULTS;
my $count = 20;
$c->stash(
data => $items,
dataRowCount => scalar @$items,
totalCount => $count,
pageSize => $pageSize,
);
}
In Controller::Vendor
sub viewform : Chained('row') Args(1) {
my ( $self, $c, $view ) = @_;
$c->stash(
template => 'simpleItem.mas',
view => $view,
);
}
The simpleItem.mas template requires data, dataRowCount, totalCount, pageSize, so grabbing the stash from Controller::ShoppingCart::pageData would be ideal.