In the view component I usually need at least a mandatory field. For example all fields that in the database are "not null".
The user, usually, doesn't know if a field is mandatory or not.
So I extended YTextField, implements YIValidatorComponent and create MandatoryTextField. The class is very easy (i create a lineBorder if the value isn't valid).
I tested it and works fine.
What do you think about the idea of create 2 new method in YComponent:
-) setMandatory (with method isMandatory) to set if YComponent is Mandatory or not (default no)
-) setMandatoryColor (get) to set/get the border color when the field null or empty
So all YComponent can be mandatory only setting to true the setMandatory property...
Do you thik it's a good idea?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think this solution is good in your case. But I wouldn't want to add this feature in the framework, since there is no standard "mandatory behaviour" for all applications. For example my customer just wants asterisk in the label next to the field. Also, YComponent is not superclass for TikeSwing components, so this change would mean code changes to all components. I try to keep the component interface as simple as possible.
Anyway, if you extend all the necessary components in your application, the result should be same.
Tomi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
In the view component I usually need at least a mandatory field. For example all fields that in the database are "not null".
The user, usually, doesn't know if a field is mandatory or not.
So I extended YTextField, implements YIValidatorComponent and create MandatoryTextField. The class is very easy (i create a lineBorder if the value isn't valid).
I tested it and works fine.
What do you think about the idea of create 2 new method in YComponent:
-) setMandatory (with method isMandatory) to set if YComponent is Mandatory or not (default no)
-) setMandatoryColor (get) to set/get the border color when the field null or empty
So all YComponent can be mandatory only setting to true the setMandatory property...
Do you thik it's a good idea?
I think this solution is good in your case. But I wouldn't want to add this feature in the framework, since there is no standard "mandatory behaviour" for all applications. For example my customer just wants asterisk in the label next to the field. Also, YComponent is not superclass for TikeSwing components, so this change would mean code changes to all components. I try to keep the component interface as simple as possible.
Anyway, if you extend all the necessary components in your application, the result should be same.
Tomi