Programming question

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Programming question

Postby patrick » Sun Jun 20, 2004 4:49 pm

Hello, I have a question:

I have a method that shows a formindialog and then goes on to do many things. The formindialog has a button "OK" and a button "Cancel". If the user hits Cancel, I do not want things to go on. What is the best way to implement this?

Something needs to happen after application.showFormInDialog.

Thanks
Patrick
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby IT2Be » Sun Jun 20, 2004 8:13 pm

Don't know if this is the best way to do this but I would define a form or global variable that is checked every time the method 'does it's thing'.

When you show the form you set the variable to 1 and by hitting the cancel button you set the variable to 0.

When you want to completely cancel all 'things that have been done' you can use a transaction that you rollback on hitting the cancel button.

Does this help? Or am I thinking the wrong way?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby patrick » Mon Jun 21, 2004 9:08 am

Thanks for your answer. A transaction doesn't do it because the real "data action" starts after the dialog. The global is the only way I see to do it but it sounds a little like "doing it the FM way", if you know what I mean.
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby automazione » Thu Jun 24, 2004 9:46 am

patrick wrote:..... global is the only way I see to do it but it sounds a little like "doing it the FM way", if you know what I mean.


May be more elegant and less "FM way" can be to define the global variable "on the fly" and not "hard-wired" in the data structure:

Code: Select all
quick_var = 0;
application.showFormInDialog(....);
if (quick_var == 1) .....


and in the method associated to the cancel button (and to the onHide property):

Code: Select all
quick_var = 1;


ciao
Enrico Arata
Servoy Italia
automazione
 
Posts: 366
Joined: Thu Apr 24, 2003 11:37 am
Location: Torino, Italy


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 53 guests