On Dec 25, 2009, at 8:09 PM, Jacek Kałucki wrote:

> I have a data control bounded with database field that is validated 
> dynamically.
> I mean, validation expression is based on current date.
> To my great surprise I found that data I entered some time ago gets invalid,
> when I browse them.

        The fault here is actually how you're doing the validation. If the 
validity of a value in a field is dependent on the time the record is created, 
you need to code your validation to reflect that. Right now it sounds like 
you're not comparing the record creation time, but rather the current time. By 
definition, all of your records will be invalid except those you just created.

        Instead, store the creation timestamp and use that for validation, or 
have your bizobj check to see if the record is new, and only do the check in 
that case. 

> After digging in code I found that dDataControlMixinBase.update() method,
> after taking control value from database, fires flushValue() method, which:
> - validates value
> - writes control value to database.
> IHMO this is completely redundant and should be done only after
> interactive value change.

        There are reasons why it needs to be done at times other than a user's 
actions, but I agree that in the case of the value being set from the 
DataSource, no flush and/or validation should be done. I've posted an update 
that should take care of that; please test it and let me know if it solves the 
issue you are seeing.

> This behaviour with conjunction with broken numeric type handling
> in dMaskedTextBox class (setting dMaskedTextBox.Value to value
> of numeric type doesn't return numeric type value but string instead)
> causes that data cursor memento becomes dirty when there were
> no real changes in data value.
> Is this everything by design?

        dMaskedTextBox is an altogether different animal. It is much stricter 
than validation you write yourself. I find them too restrictive to be of much 
practical use in most cases; typically, it's faster to write my own data 
manipulation code.

> And yet another question, why only dTextBox class implements
> _inFlush semaphore but not entire data based control set?

        Because we use text boxes to show all sorts of values, but wx only 
allows strings. There is an additional translation step, and _inFlush was added 
to avoid the multiple calls from the different layers.


-- Ed Leafe




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to