Form_Run called
Form_Create called
Form_PreRender called
Qcodo Development Framework - Examples
4. Basic QForms
Understanding Process Flow
<< QForms: Stateful, Event-Driven Objects   |   Back to Main   |   Calculator Example >>

View Source
will open in a new window
Understanding the QForm Process Flow
First of all, don't adjust your screen. =)

The "Form_blah called" messages you see are showing up to illustrate how the QForm process flow works.

As we mentioned earlier, QForm objects are stateful, with the state persisting through all the user interactions (e.g. ServerActions, etc.). But note that QForm objects are also event-driven. This is why the we state that QForms is a "stateful, event-driven architecture for web-based forms." On every execution of a QForm, the following actions happen:
  1. The first thing the Form object does is internally determine if we are viewing this page fresh (e.g. not via a post back) or if we have actually posted back (e.g. via the triggering of a control's action which would post back to the server).
  2. If it is posted back, then it will retrieve the form's state from the FormState, which is a hidden form variable containing the serialized data for the actual Form instance. It will then go through all the controls and update their values according to the user-entered data submitted via the post, itself.
  3. Next, regardless if we're post back or not, the Form_Run method (if defined) will be triggered. Again, this will be run regardless if we're viewing the page fresh or if we've re-posted back to the page.
  4. Next, if we are viewing the page fresh (e.g. not via a post back), the Form_Create method (if defined) will be run (Form_Create is typically where you would define and instantiate your various QForm controls). Otherwise, the Form_Load (if defined) will be run.
  5. Next, if we're posted back because of a QServerAction or QAjaxAction that points to a specific PHP method, then the following will happen:
    • First, if the control that triggered the event has its CausesValidation property set, then the form will go through validation. The form will call Validate() on the relavent controls, and then it will call Form_Validate on itself. (More information on validation can be seen in the upcoming Calculator examples.)
    • Next, if validation runs successfully or if no validation is requested (because CausesValidation was set to false), then the PHP method that the action points to will be run.
    So in this repeat of the "Hello World" example, when you click on btnButton, the btnButton_Click method will be excuted during this step.
  6. If defined, the Form_PreRender method will then be run.
  7. The HTML include template file is included (to render out the HTML).
  8. And finally, the Form_Exit (if defined) is run after the HTML has been completely outputted.
So, basically, a QForm can have any combination of the five following methods defined to help customize QForm and QControl processing:
  • Form_Run
  • Form_Load
  • Form_Create
  • Form_Validate
  • Form_PreRender
  • Form_Exit

Click the button to change my message.

Form_Exit called