There are a couple of ways to tackle this problem ... The first and most straight-forward is to pass the parameters set in the first run-mode back into hidden form fields or anchor links within your template file. This method is demonstrated in the code snippet below:

. . $html->param( $_ => $self->param($_) ) foreach $self->param(); return $html->output; }

For which the corresponding HTML::Template template file would look similar to the follow:

. . <input type="hidden" name="rm" value="list" /> <input type="hidden" name="id" value="<tmpl_var name="id">" /> <input type="hidden" name="name" value="<tmpl_var name="name">" /> . .

This is the most simple and correspondingly most insecure manner for providing state persistence between run-modes using CGI::Application.

A far better approach to this issue of state persistence is to make use of a server-side based persistence solutions such as that offered by Apache::Session and CGI::Session - I demonstrated an example of such a server-side based persistence solution for CGI::Application with this post.

With this method, only a reference to the server-side storage of persistence data is sent to the client and as such these solutions offer greater security as persistence data is not directly accessible to the client. This is important with clients who with the former method could easily edit the HTML form values and return bogus data - For a further discussion on this, see Re: A CGI chained-event theory question.

 


In reply to Re: Passing values between run modes in CGI::Application by rob_au
in thread Passing values between run modes in CGI::Application by Rich36

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.