[ovirt-devel] IntegerEntityModelTextBox*, NumberEntityModelTextBox*, Validate

Alexander Wels awels at redhat.com
Thu Jan 12 20:55:59 UTC 2017


On Thursday, January 12, 2017 8:16:58 AM EST Tomas Jelinek wrote:
> Hi,
> 
> the validation should be done not on widget level but on the whole model
> level. In case of the random generator which is in the VM dialog, it should
> be validated in the UnitVmModel (the backing model of all the VM-like
> entities) and inside it in the validate() method. Than this validate()
> returns true/false if it is valid / invalid. And than the corresponding
> list model (VmListModel.onSaveVm() for example) calls the validate and only
> if it passes it should continue to send the data to server.
> 
> Is this not what happens?
> 
> Tomas
> 

Actually Integer/Long entity model boxes do checks at the widget level to make 
sure what is entered is actually a number, however it obviously can't know 
anything about business logic validation. So what it does is mark the field 
invalid, but doesn't send the value to the actual model (it can't since the 
model is expecting a number and trying to send a string to a number field will 
cause an exception). So the backing model will contain whatever value was 
there before if the user entered a non number value in the field.

When you click OK the business logic validation happens on the values of the 
model and not the values of the fields. If the model didn't change due to the 
above it will validate against the current value which may or may not pass 
depending on the validation rules.

> On Thu, Jan 12, 2017 at 2:38 AM, Tony Wang <sline798 at gmail.com> wrote:
> > I find the TextBox Widget of ovirt-engine,such as
> > IntegerEntityModelTextBoxEditor. They are weak in validation. When i
> > input a string or something else can't parse Integer. In view, the widget
> > will make as invalid, but i press the button of "OK", it always can pass.
> > Even, when i edit the entity's attributes, such as Random Generator's
> > Period or Bytes per period of VM, use IntegerEntityModelTextBox* widget,
> > it
> > will save the old data. I can't be sure this is a fault or is normal?
> > 
> > _______________________________________________
> > Devel mailing list
> > Devel at ovirt.org
> > http://lists.ovirt.org/mailman/listinfo/devel




More information about the Devel mailing list