Only you know how to link to stuff in your web application, so no size will ever fit all; a generalized solution will probably never meet all requirements.

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:

<TABLE class="items"> % foreach my $item (@items) { <TR><TD><% $item->link( %ARGS ) %></TD></TR> % } </TABLE>
The corresponding Item.pm module might contain something like this:
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.

-- Time flies when you don't know what you're doing

In reply to Re: Links between Mason components? by FloydATC
in thread Links between Mason components? by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.