Servoy error validation

Questions, tips and tricks and techniques for scripting in Servoy

Servoy error validation

Postby eKelman » Tue Apr 26, 2011 12:53 am

Hello all,

I have a situation regarding servoy validatoin for fields marked as not "Allow Null".

I have a form based on a table. the two fields on the form are not nullable. One is a drop down, the other is a text field

a) if we don't set any values and click a button to "Save" the data, we can trap the error and display our own error message to the user.
b) if we set the drop down value and leave the text value untouched we can trap the error and display our own error message to the user
c) if we delete the text value and leave the drop down value we can trap the error and display our own error message to the user

here's were it gets weird.

1) set both values.
2) set the drop down to an empty value.
the drop down goes red
3) Click ok, nothing happens. The form appears locked.
the server log shows:
Error Handler (Non-Oracle error): Invalid input, Validation failed for 'field_name', with value: null User: user@0:0:0:0:0:0:0:1 Form: Element: Servoy Error Code: 310
4) now set the drop down to a value and clear the text
5) try to click okay, the text field retains focus and similar error is displayed in relation to this field value.

I can see that servoy is trying to handle this issue, problem is the user has no idea whats happening behind the scenes as our dialog won't be displayed anymore.

Could someone explain what might be going on? and how do I get around this issue?

Thanks


Servoy Version: 5.2.7 - build 1013
Windows XP/7
Firefox Version 3.6.16
Ernest
Kelman Technologies
eKelman
 
Posts: 52
Joined: Tue May 12, 2009 9:09 pm

Re: Servoy error validation

Postby jcompagner » Tue Apr 26, 2011 11:42 am

Click ok, nothing happens. The form appears locked.
the server log shows:
Error Handler (Non-Oracle error): Invalid input, Validation failed for 'field_name', with value: null User: user@0:0:0:0:0:0:0:1 Form: Element: Servoy Error Code: 310


but this is a servoy exception (the null check) that calls your solution.onError method..
Are you saying that that method is not called? in this situation?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Servoy error validation

Postby eKelman » Tue Apr 26, 2011 6:48 pm

Hi Johan,

The solutions solution.onError method is being fired in this situation.

The issue here is that our own error handling is not being called after the servoy exception has been fired.

I tried to incorporate the code from the example but the servoy exception stops the user from being able to close a new modal window.

Code: Select all
  if (ex instanceof ServoyException)
  {
    switch (ex.getErrorCode())
    {
      case ServoyException.SAVE_FAILED:
      case ServoyException.INVALID_INPUT:
        forms.graphics_template_dialog.setup_dialog(null, 'Error Handler', 'It seems you did not fill in a required field', 'Ok'); 
        return ;
      default:
        return;
    }   
  }


Is there any way to get around that? or is there a way to stop servoy exception handling in certain cases? we have our own error handling that would prevent a user from proceeding until they have passed our validation.
Ernest
Kelman Technologies
eKelman
 
Posts: 52
Joined: Tue May 12, 2009 9:09 pm

Re: Servoy error validation

Postby jcompagner » Wed Apr 27, 2011 10:26 am

Ernest,

i don't see the complete picture here, when is your code being called? What is the trigger?
That code is behind the button?
So you really don't want servoy to do the null validation?
that you can configure:

databaseManager.setNullColumnValidatorEnabled(false)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Servoy error validation

Postby eKelman » Wed Apr 27, 2011 5:52 pm

Johan,

Our code is being called on the onAction trigger of a button when a user clicks okay to close the dialog.

After the button is clicked we call a "PreCheck" function to validate the data is complete / valid. In this case we verify that both "not nullable" fields are set before allowing the user to continue.

Some scenarios on the form with two fields are
a) if we don't set any values and click the "Save" button the data, we can trap the error and display our own error message to the user.
b) if we set the drop down value and leave the text value untouched, and click the "Save" button, we can trap the error and display our own error message to the user
c) if we delete the text value and leave the drop down value, and click the "Save button", we can trap the error and display our own error message to the user

One of the issues it that the built in null validation doesn't execute in all instances and only occurs after a value has been set and then removed.

I can try to remove validation and then reapply it after the form closes.
Ernest
Kelman Technologies
eKelman
 
Posts: 52
Joined: Tue May 12, 2009 9:09 pm

Re: Servoy error validation

Postby jcompagner » Wed Apr 27, 2011 6:10 pm

eKelman wrote:
One of the issues it that the built in null validation doesn't execute in all instances and only occurs after a value has been set and then removed.


and that's on purpose.
A user shouldnt get error messages or something if he just tabs over the field besides that, the null check is only done when the user changes data.
So when a null is tried to be set, and that is never the case if the user does nothing with the field.
So yes those validation should be done another time (for example your button click or table events)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Servoy error validation

Postby eKelman » Wed Apr 27, 2011 10:05 pm

Johan,

is there any way to get feedback to the user regarding items that need to be filled in?
do you know of a css value that we could set to make it more visible to the user?

Modifying the solutions onError method fails for us because the user is not able to close the new dialog window opened from the solutions on error method (via a button action). It can be closed if the user clicks the "X" twice.

Ernest
Ernest
Kelman Technologies
eKelman
 
Posts: 52
Joined: Tue May 12, 2009 9:09 pm

Re: Servoy error validation

Postby jcompagner » Thu Apr 28, 2011 10:11 am

why don't you use the databaseManager.setNullColumnValidatorEnabled(false) ?
then you can do it all in your method and we don't do it.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 10 guests