how to tell what form is currently open

Questions, tips and tricks and techniques for scripting in Servoy

how to tell what form is currently open

Postby eKelman » Thu Apr 07, 2011 10:09 pm

hi all,

is there a way to tell which form is currently open? or if a form is currently open?

Situation:
1) The user opens a form with some text fields.
2) places the form into an editable status
3) changes some value that does not conform with ondatachange event
4) while that field is still in focus, the user clicks save
5) ondatachange event opens a dialog stating that this value is not valid.
6) ondatachange event sets that value to null
7) application continues to save record after we clear that field.

Is there any way to stop the save method from continuing? I was thinking I could utilize some method that would tell what form was open.
currentcontroller.getFormContext()[0][1] works only the first time. After the user closes that dialog it comes back with the original form name
Ernest
Kelman Technologies
eKelman
 
Posts: 52
Joined: Tue May 12, 2009 9:09 pm

Re: how to tell what form is currently open

Postby lwjwillemsen » Thu Apr 07, 2011 10:45 pm

Hi ?,

We do :

6) ondatachange event sets that value to the old value

This way the following save is ok.

PS. I consider showing your own full name in the forum as friendly.

Regards,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 680
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

Re: how to tell what form is currently open

Postby eKelman » Fri Apr 08, 2011 12:06 am

Thanks for the reply Lambert,

We set the value to null to allow the save, but our users are not too happy with a value they've entered disappearing and then having to activate edit mode and renter the value etc.

I guess the main issue is getting the application to stop that process and allow the user to rectify their error before the continuing with the save.

There are no problems if the user changes focus and then proceeds to do the save.

I just thought if i could get the top most form at the time, because its a modal dialog, then i would be able to stop the save from happening.

Using currentcontroller.getFormContext()[0][1] works the first time, meaning it does pick up the correct form name. But, if the user enters another invalid value, the form name passed is incorrect the second go round.
Ernest
Kelman Technologies
eKelman
 
Posts: 52
Joined: Tue May 12, 2009 9:09 pm

Re: how to tell what form is currently open

Postby lwjwillemsen » Fri Apr 08, 2011 8:47 am

Hi Ernest,

You can set a form or global variable when the error is displayed and the save function can check that variable...

Some housekeeping must be done for such a flag. If you work with your own 'standard' UI functions for error / warning display you have less work to implement application wide.

Regards,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 680
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 19 guests