Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Form validation in Contacts Application(The validation of first name and last name does not seem to work properly)
Form validation in Contacts Application [message #1767676] Sun, 09 July 2017 09:32 Go to next message
Stéphane Levy is currently offline Stéphane LevyFriend
Messages: 6
Registered: July 2017
Junior Member
Hello,

I am experimenting a strange behavior on the "New person" form of the Contacts Application. It concerns the validation of the first name and last name, one of them at least must be fill.
This works properly at the beginning, I am able to enter a person with only a first name or a last ame.
The problem occurs when I follow this actions :
- I first submit a form without a first name and a last name
- I get an alert : Missing Name (this alert is normal)
- I then fill a first name or a last name or both and when I submit, I have an alert different from the first one : "The following fields are invalid : General : Missing name"
- The form can not be submitted any more.

I have reproduced this behavior with eclipse scout 6.0.300.RC2 and 7.0.0-SNAPSHOT and in the deployed app in https:// scout.bsi-software.com/contacts/

I am using Firefox 54.0 (32 bits) on Ubuntu 16.

I don't think this behavior is normal, can you reproduce it ?
Is it a bug ?

Thank you very much.
Re: Form validation in Contacts Application [message #1767677 is a reply to message #1767676] Sun, 09 July 2017 09:52 Go to previous messageGo to next message
Matthias Zimmermann is currently offline Matthias ZimmermannFriend
Messages: 208
Registered: June 2015
Senior Member
definitively sound's like a bug, thanks for reporting. we will look into this shortly.
matthias
Re: Form validation in Contacts Application [message #1767694 is a reply to message #1767677] Mon, 10 July 2017 04:23 Go to previous messageGo to next message
Matthias OtterbachFriend
Messages: 55
Registered: August 2015
Location: Munich
Member
I can confirm this bug, there is a custom org.eclipse.scout.contacts.client.person.PersonForm.execValidate() method which adds an error status to the PersonForm.MainBox.GeneralBoxGeneralBox on the first time either the first or the last name field is not filled correctly.

The next time the form is validated every field is checked if they are valid. As the PersonForm.MainBox.GeneralBoxGeneralBox is not valid anymore (an error status was added the last time the form was validated) the second message is shown. As there are already invalid fields, the whole form is not validated again anymore (the execValidate method above is not called again even though this one seems to be implemented to remove the error status from the group box if all fields are valid now).
Re: Form validation in Contacts Application [message #1768295 is a reply to message #1767694] Mon, 17 July 2017 07:46 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 205
Registered: November 2010
Senior Member
Stéphane,

Matthias is right, the form validation code here is not quite correct. I will try to improve the form in the following weeks. Thanks for pointing that out!

Basically, manually adding an error status to a field is only required for complex cases. If you do that, you have to make sure the status is also removed when the field values become correct. (This is what doesn't happen in the contacts app.)

For most cases however it should be sufficient to override execValidateValue() (field validation) or execValidate() (form or form handler validation) and throw a VetoException with a corresponding message if the validation fails. Mandatory fields can be marked by setting getConfiguredMandatory() to true. This property can also be manipulated at runtime using field.setMandatory(true), for example in the execValueChanged() of another field.

Regards,
Beat
Re: Form validation in Contacts Application [message #1768427 is a reply to message #1768295] Tue, 18 July 2017 14:23 Go to previous messageGo to next message
Stéphane Levy is currently offline Stéphane LevyFriend
Messages: 6
Registered: July 2017
Junior Member
Thank you very much for your help and your concern.
Re: Form validation in Contacts Application [message #1817765 is a reply to message #1767676] Thu, 28 November 2019 18:04 Go to previous message
Rodrigo Llanos is currently offline Rodrigo LlanosFriend
Messages: 2
Registered: November 2019
Junior Member
One posible solution that works is, add a second line of code, to clear the error status of the general box: statusgetGeneralBox().clearErrorStatus(); before throw new VetoException.

@Override
protected boolean execValidate() {
boolean noFirstName = StringUtility.isNullOrEmpty(getFirstNameField().getValue());
boolean noLastName = StringUtility.isNullOrEmpty(getLastNameField().getValue());

//getGeneralBox().clearErrorStatus();
if(noFirstName && noLastName) {
getGeneralBox().addErrorStatus(TEXTS.get("MissingName"));
getFirstNameField().requestFocus();
getGeneralBox().clearErrorStatus();
throw new VetoException(TEXTS.get("MissingName"));
}
return true;
}
Previous Topic:How I can localize texts in ui javascript (frontend)
Next Topic:Firebase Authentication and Cloud Firestore
Goto Forum:
  


Current Time: Wed Apr 24 23:10:12 GMT 2024

Powered by FUDForum. Page generated in 0.04834 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top