John wrote:
> On Monday 26 October 2009 06:23:25 am Ed Leafe wrote:
>> try:
>> myBiz.validateUserInput(val)
>> except dException.BusinessRuleViolation, e:
>> dabo.ui.stop("Invalid entry: %s" % e)
>>
>> It's a much more Pythonic approach, and keeps the UI separate from
>> the bizobj layer logic
>
> I have often wondered just how Form.validateField() actually worked and the
> thinking behind it. I think it only works at the save().
>
> So could you explain how it's suppose to be done in code.
>
> Also many of us are looking for something like your "validateUserInput(val)"
> at the time of lostFocus (or a when()). For example I discovered that my
> client was entering a string ('250') into a dDateTextBox by accident and it
> was not being caught until it created a real problem (backend error). I at
> first added the field to the bizObj.validateRecord. But the client did not
> like the fact that the system did not immediately warn them after leaving the
> control. I then added a lostFocus routine.
>
> Is there a simple way to add validation at the UI level? Or tell me the
> thinking behind not having any validation (that I'm aware of) at the UI
> level.
>
> Thanks in advance
I believe all you need to do is put a fieldValidation()[1] method into your
bizobj,
and Dato handles field validation (immediate when the user tries to leave the
field).
Then in your dForm subclass, override either onFieldValidationFailed() and/or
onFieldValidationPassed(), which lets you augment or override the default
behavior
(of setting focus to the control again in the case of
onFieldValidationFailed()).
I personally would only use field validation for warning the user, without
stopping
the focus from moving away. And I'd warn the user by using the status bar or
some
other modeless output, instead of popping up an annoying dabo.ui.stop() or some
such.
So, it looks like Dabo has what you want already, but I haven't ever tried
field
validation myself. I use record validation for everything, but will consider
using
field validation to catch problems early on for the purpose of warning the user.
[1] Confusing that it is biz.fieldValidation but dForm.validateField()
Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]