in reply to Question about designing a web app using CGI::Application

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!

  • Comment on Re: Question about designing a web app using CGI::Application