CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Validation still has problems

General discussion

by asp » 28 Apr 2014 11:16

Hello!

I've made a project showing a problem with validation. Once again IsValid property works incorrect. Now, it contains false when actually validation must return true. May be it happens when you create controls dynamically. See attached project.
You do not have the required permissions to view the files attached to this post.
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

by Alexander Bulei » 28 Apr 2014 16:58

Hi asp,

Can you explain better?

Maybe this topic help you: viewtopic.php?f=3&t=1366

Video attached.

Best Regards.
You do not have the required permissions to view the files attached to this post.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by asp » 29 Apr 2014 08:50

The issue is shown on your video :) When you press OK button, the dialog should close because the validation succeeds (it can be noticeable by the green frame around the edit).
But when we test IsValid property on the server side, it will contain false, so we don't close the dialog. See the code:

Code: Select all
procedure TfrDia.IWFrameRegionJQDialogOptionsButtons0Click(Sender: TObject;
  AParams: TStringList);
var C: TComponent;
    JQValidateOpt: TIWCGJQValidateOptions;
begin
  for C in IWFrameRegion do begin
    if IsPublishedProp(C, 'JQValidateOptions') then begin
      JQValidateOpt := TIWCGJQValidateOptions(GetObjectProp(C, 'JQValidateOptions'));
      if JQValidateOpt.Enable then begin
        JQValidateOpt.Validate;
        if not JQValidateOpt.IsValid then begin
          Exit;
        end;
      end;
    end;
  end;
  IWFrameRegion.JQDialogOptions.Close();
end;


The dialog will be closed if we press OK button for the second time.
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

by asp » 30 Apr 2014 11:02

Hi!
Was my explanation clear enough? Do you see the problem?
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

by Jorge Sousa » 30 Apr 2014 11:06

Hello

You cannot call JQValidateOpt.Validate that performs the validation in the browser, and immediatelly call JQValidateOpt.IsValid to check, because only the next event will be valid.

ie, JQValidateOpt.Validate doesn't call the browser, waits and backs to server.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by asp » 30 Apr 2014 13:54

Hi!

Consider very natural use case.
We have a form with several controls and OK button.
When an user presses OK button we want to check if all values are valid, and if it is so, post these values to the database.

If I understand your words correctly, it is impossible now. But it means that this validation is useless.
A method which would run a validation process and return the result is heavily needed.
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

by Jorge Sousa » 30 Apr 2014 14:17

Hi

You just have to make our app call validate before the ok button, eg, edit change

It's not impossible, and doesn't make the validation useless, like you say.

Ok, we can always improve and do that internally every time a control with change , when validateoptions is active, i think is a better solution for this case.

We don't go running and preview the million thing we could do...

This should be added in very short time,
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by asp » 30 Apr 2014 15:03

Hi!
I think that doing validation when control value is changed won't help. For example, if we have an empty edit with required validation rule, the user may simply press OK without touching the edit, and the edit will not be validated in this case.

I pay so many attention to the validation because it is one of the most important aspects of the GUI, more important than other bells and whistles.
Best regards.
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

by Jorge Sousa » 30 Apr 2014 15:57

Hello

The attached file contains a few changes to your demo,

that transforms the dialog button's OnClick.OnEvent into OnClick.Script, adding the javascript to call Validate to each validated control

we can make an internal method to be more natural.

Please tell me your thoughts
You do not have the required permissions to view the files attached to this post.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by asp » 01 May 2014 04:40

Hi!
Thank you. I'm on vacations now, so I can't test the project for the moment. I'll write you after the holidays. May be you will have the internal method by that time :)
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

Next

Return to General - Archive

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.