Form processing

| No Comments | No TrackBacks

Once I start on a problem I have a difficult time letting go until I have a solution. I mentioned forms processing in my last entry and I have been crunching on it ever since.

I have found that the major problem with the original design had more to do with a poor OO methodology than a bad design. I just need to get the pieces separated into the correct objects. Therefore, I've build a new OO API for forms processing.

Okay, I've separated the system out into the following pieces:

  • Context - a transient object that collects all the information pertinent to the current request
  • Session - a persistent object that collects all the information connected with a particular user's session
  • Setting - a persistent object containing application-wide settings
  • User - a persistent object containing information about a user that exists across sessions
  • Form - an object stored in Settings that describes the structure of a form
  • Submission - a transient object that exists initially when a Form is written to a response and again if the user POSTs that form back in a request
  • Action - a functor object that performs some action using data from a processed Form Submission
  • Widget - an object that both renders some set of controls in a response used to form a POSTed request and a functor that performs some processing of Submission data on behalf of a Form before the form's Action is executed
  • Map - an object used to determine how the response should be constructed when interacting with a Form
  • Panel - a box in the response containing whatever object the Map says it should contain, the topmost Panel, __DEFAULT__, can be used to affect the entire response

The use-case is basically like this: The response has a Panel placed in it (possibly the __DEFAULT__). This Panel specifies a Map, which determines what sub-response to place within the Panel. Typically, this is some sort of Form, to being with. The Form is drawn to the response and stored in the Settings (keyed by a application-unique name). The Form determines the Action that is run on the receipt of an activated Submission. A Submission is initially created to associate a UUID with the submission and to remember the Map used so that an activated Submission received later will operate according to the original Map behavior. Finally, the user gets a copy of this form in her browser and fills in the details of the form. Once filled, the form is submitted back, which creates an activated Submission object. The Submission object then causes the Form to process all the incoming information via it's Widgets. Assuming successful processing by all Widgets, the Form then runs the Action. Based upon the Action result, the Map is then used to determine how to render the response. This generally involves an immediate 302 Redirect to the next page in the Map and then the Map is used within that page to determine how to render the content there.

Phew! The details of this whole process are almost entirely handled internally to Contentment (or will be when I release the next trunk revision). The only the thing the programmer will have to do is to create a Form with Widgets, create an Action to handle the Submission, and a Map to determine what to do next, based upon the output of the Action. This creates a nice HTTP-centric MVC architecture where the Action/Map form the controller, the Submission forms the model, and the Form/Widgets form the view.

No TrackBacks

TrackBack URL: http://contentment.org/mt/mt-tb.cgi/502

Leave a comment

About this Entry

This page contains a single entry by Andrew Sterling Hanenkamp published on March 8, 2005 8:28 AM.

Contentment running two, soon three was the previous entry in this blog.

CIS Support Site switches to Contentment is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.