There have been two references here so far to responses to a post by me. So I thought I would chip in as well.

In general I have decided that it is best to use a separate runmode for each action. One to render a form, one to process the submitted result. Then it is possible to easily use CGI::Application::validateRM for input validation and error presentation. The combination of these modules makes the process of managing forms and data rather easier than any other way I have tried.

Using a single runmode for form rendering and input processing narrows the choices you have for validation. It also has another interesting side effect - you can get better code re-use! I have found that the form processig runmode can often be re-used itself. The same basic logic is used to validate and process data for a single entity, say a database record, in possibly several places in an application. As an example, I have an appointment record (in an appointment management system) which is accessible either by the person wanting an appointment or the service provider. Validation and processing is the same regardless of the user, but the form presented is very different, often with different popup menues and defaults in the various cases. If I want to go to different places when the validation and processing is complete, I can just use the get_current_runmode method of CGI::Application and do a dispatch at the end of the runmode.

One cat, just more ways to skin it.

John

Don't worry about the rest of us out here. We are used to picking up code which is written in strange ways!


In reply to Re: Question about designing a web app using CGI::Application by jdtoronto
in thread Question about designing a web app using CGI::Application by disciple

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.