Hi,
what is the difference between the two methods of a Validator, TranferFromWindow and Validate?
Are they treated differently somewhere in wx or are
they always called together and are only there to highlight the different stages?
I.e., does it make any difference if one transfers the validation code from Validate to TranferFromWindow?
Hi Patrick,
I am still in no way an expert in all this stuff, so take all this with a grain of salt.
Hi,
what is the difference between the two methods of a Validator, TranferFromWindow and Validate?
Are they treated differently somewhere in wx or are
they always called together and are only there to highlight the different stages?
- TransferFromWindow (TFW) is normally used to get the data from the Window and persist it, i.e. write it to a database.
- Validate checks that the controls data is valid
In my view these are pretty distinct, no. Normally you wouldn't want to do TFW without first having done Validate, but you might want to do Validate without certainly doing TFW at that point, e.g. validate that control values on a notebook page are valid before allowing the user to switch to another page ......
I.e., does it make any difference if one transfers the validation code from Validate to TranferFromWindow?
Why are you tempted of doing this?
In the past I might have done this type of stuff too, i.e. have a method which does it all (or at least lots of things). I am starting to get much better in breaking things down into smaller chunks/methods which do one thing only and then have a method higher up in the hierarchy which calls the different methods. Advantage I now see is that I get better/more code reuse and it is a lot faster/easier to debug things.
Werner
···
On 14/04/2012 10:25, Patrick Ruoff wrote:
Hi Werner,
Hi Patrick,
I am still in no way an expert in all this stuff, so take all this with
a grain of salt.
Hi,
what is the difference between the two methods of a Validator,
TranferFromWindow and Validate?
Are they treated differently somewhere in wx or are
they always called together and are only there to highlight the
different stages?
- TransferFromWindow (TFW) is normally used to get the data from the
Window and persist it, i.e. write it to a database.
- Validate checks that the controls data is valid
In my view these are pretty distinct, no. Normally you wouldn’t want to
do TFW without first having done Validate, but you might want to do
Validate without certainly doing TFW at that point, e.g. validate that
control values on a notebook page are valid before allowing the user to
switch to another page …
I.e., does it make any difference if one transfers the validation code
from Validate to TranferFromWindow?
Why are you tempted of doing this?
Ok, let me try to motivate this:
I’m trying to develop a small “library”, that makes the usage of xrc dialogs much easier.
As input, I want to use plain xrc files, which are loaded by the an xrc dialog class.
The problem is now, that you cannot use custom controls in xrc easily,
so I want to customize the standard controls
with a generic validator class, which the user can modify by plugging in special transfer functions.
This generic validator class then mediates between the controls value (in view) and a data item (in model) with the TTW and TFW functions.
The Validate method is only used for data type conversion, but other tests can only be performed after the transfer function
converted from view to world space, so validation is also done in TFW.
I wonder if this has any negative effect or if the function Validate only exists for convenience.
···
On Saturday, April 14, 2012 4:15:42 PM UTC+2, werner wrote:
On 14/04/2012 10:25, Patrick Ruoff wrote: