Ed Leafe wrote:
On Sep 5, 2005, at 11:43 AM, david whiting wrote:

If I understand dabo correctly the model validates whole records in
one go (validateRecord). It may be bad style on my part, but I tend to
need the equivalent of (old?) Foxpro's VALID() and WHEN() clauses at
the field level. In particular I need to create double-entry systems
in which the second entry not only has to be valid with respect to the
validation rules, it has to be compared with the first entry to detect
entry errors. This works best on a field-by-field basis.


Right now there isn't any field-level validation. If you want to add that behavior, you'll have to bind to the LostFocus event for the control, using something like:

txtField = dabo.ui.dTextBox(self, DataSource=..., DataField=...)
txtField.bindEvent(dabo.dEvents.LostFocus, self.fieldValidate)

def fieldValidate(self, evt):
    ...

Note that unlike the Fox VALID() event, LostFocus fires *after* the control has lost focus, so if you want to keep the user in that textbox, call its setFocus() method.

This brings up an interesting thought - we already bind to the LostFocus event for any data control, and call a private method that flushes the value back to the DataSource. What if we were to set up an empty 'lostFocus()' method that is automatically called, much as we do for the beforeXX() and afterXX() events? This way if a developer wants to add field-level validation, or any other sort of update when a control loses focus, they simply write the method, and it gets called automatically? The problem, of course, is that you are dealing with control instances, and it is tougher to handle coding instance behavior.

It seems to me this should hook into the bizobj, not into the ui form. Ask the bizobj if the field data is okay or not.

--
Paul McNett
http://paulmcnett.com
http://dabodev.com


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to