11. MetaControls, Meta DataGrids, and the Drafts
* Introduction to MetaControls
<< QForm and CodeGen, a Winning Combination to RAD
|
Back to Main
|
* Introduction to Meta DataGrids >>
View Source
will open in a new window
Generated MetaControl Objects
As you build out more and more database-driven
QForms
and
QPanels
, you'll notice that you still may spend quite a bit of wasted time coding the same type of Control definition, setup and data binding procedures over and over again. This becomes especially tedious when you are talking about modifying objects with a large number of fields.
Utilizing QControls and the code generator, QCubed can generate
MetaControl
classes for each of your ORM classes.
MetaControls
are essentially classes which contains functionality to simplify the
QControl
creation/definition, setup and data binding process for you.
Essentially, for each field in a class, you can have the
MetaControl
return for you a data bound and setup
QControl
for editing, or even a
QLabel
just for viewing. But because these MetaControls are simply returning standard QControls, you can then modify them (stylizing, adding events, etc.) as you normally would any other control. You'll note in the PHP code that while it doesn't appear that we save that much in terms of Lines of Code, you will note that some of the more tedious, non application-specific code of literally making calls like
$this->txtFirstName = new QTextBox($this)
and setting up the
Text
,
Required
and
Name
properties of
$txtFirstName
is now done for you.
And because the
MetaControl
will be able to keep track
which
controls have been generated thus far, you can call (for example)
SavePerson()
on the
MetaControl
, and it will smartly go through any controls created thus far and bind the data back to the Person object.
We show this in our example below, where we have clickable labels and hidden textboxes to aid with the viewing and/or editing of Person #1.
Finally, note that because
MetaControls
encapsulate all the functionality for a given instance of a given object, and because it is able to keep track of and maintain its own set of controls, you can easily have multiple
MetaControls
on any
QForm
or
QPanel
, if you want to view or edit multiple objects of any class at the same time.
Click on any label to edit:
First Name
kavita 2
Last Name
arulyfred