in reply to Question about designing a web app using CGI::Application
I think the simple answer is that "it depends"!
I've usually processed everything related to one mode in its own handler, testing for the value of submit parameter to determine whether I need to process the form, or merely display it.
The reason that I tend to use this approach is that it lets me show errors to the user in a simple manner.
Take for example the example of a form that asks for a name and an email address.
In my HTML::Template page I will have the entry fields for the input of the values, and I will also have some stubs for error messages "You must enter an email address", etc.
This way if there is an error I can re-display the input page with the users values entered into it, and the relevent error message.
The alternative approach would be to have the handling mode have the template it was going to display and an error template - and I didn't want to have two templates which might get out of sync.
|
|---|