Here's what I usually do: I write my own modules (classes really) that represent the different entities that the web application deals with, such as users, articles, hosts or whatever. Each of those modules (classes) include a link() method which "knows" what an URL for that particular entity should look like. This method is passed with a hash argument where I pass on all the arguments that the current Mason component was called with. Example:
The corresponding Item.pm module might contain something like this:<TABLE class="items"> % foreach my $item (@items) { <TR><TD><% $item->link( %ARGS ) %></TD></TR> % } </TABLE>
sub link { my $self = shift; my %args = @_; $args{'foo'} ||= "default"; $args{'bar'} ||= "values"; return '<A href="/path/to/item.html?id='.$self->id.'&foo='.$args{'fo +o'}.'&bar='.$args{'bar'}.'>'.$self->name.'</A>'; }
There might be other elegant solutions but this approach has worked brilliantly for me over the years.
In reply to Re: Links between Mason components?
by FloydATC
in thread Links between Mason components?
by tye
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |