On 06/09/05, Paul McNett <[EMAIL PROTECTED]> wrote:
> 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.

OK. This sounds similar to the way I used to do this with Foxpro. I
had a single .PRG file with a main fld_valid() function that called
other functions that implemented the validation rules for each
control. In the VALID() clause of each control I just called
fld_valid() and sent the control name and the value entered, so it was
(almost) always the same for every control. This then returned .T. or
.F. depending on whether the data were valid.

I would try to do something similar with dabo: have the function
access the validation rule in the bizobj. But I think my desires are
somewhat ahead of my abilities at the moment and I need to learn more
python. I think I'll try something a little simpler to begin with.

Thanks.

Dave


-- 
David Whiting

_______________________________________________
Post Messages to: Dabo-users@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Reply via email to