application.getMethodTriggerElementName() in formInDialog

Hi there,

I am having a trouble with application.getMethodTriggerElementName() when the button clicked from a Form which is shown in a formInDialog.

closeForm: //this method just closes the form in dialog

application.closeFormDialog()

method_a:

application.showFormInDialog(forms.frmInputDialog, -1, -1, -1, -1, "test", false, false, false);
btnName = application.getMethodTriggerElementName();

on form frmInputDialog there are two buttons named ok & cancel respectively (both button’s onAction method name is closeForm). The close window button is already disabled.

The variable btnName should get the name of the button clicked from the form shown in formInDialog.
But it gets blank.

This happens from a few version back.

Thanks for your help.

that piece of code:

btnName = application.getMethodTriggerElementName();

should be in the closeForm code because that method is triggered by ok or cancel of the form dialog.

I am already doing like this now. But this was working both the way in the older versions.

but in the end it is very strange behaviour.

For example:

btnName = application.getMethodTriggerElementName();
application.showFormInDialog(forms.frmInputDialog, -1, -1, -1, -1, “test”, false, false, false);
btnName = application.getMethodTriggerElementName();

what should btnName be before and after?
What you ask in that script should be the trigger for THAT script.
(now it also doesn’t go quite right)

My code was like the following:

application.showFormInDialog(forms.frmInputDialog, -1, -1, -1, -1, "test", false, false, false); 
btnName = application.getMethodTriggerElementName();

It did not have a

btnName = application.getMethodTriggerElementName() before the showFormInDialog

The “ok” or “cancel” button is clicked inside formInDialog. But
btnName = application.getMethodTriggerElementName() did received the correct button name (in the main form after the formInDialog is closed)

This behaviour was in the older versions but not anymore now.

[/code]

yes i get that you didn’t do that.
But i was just explaining that it is very strange behaviour.
That suddenly the trigger things are changing inside a method . It should be always stable.. (which is still not the case but that is an other matter)

So before or after the showForm should the trigger methods return the same thing.. Because for that method you are in is triggered by a specific action and that should be always stable.. No matter what.
I will look at this later on. (so that before and after the showFormInDialog the same things will be returned)

Hi Developers

Is the described way of getting the answer of which was the pressed button in a form dialog (called with showFormInDialog) in this thread the standard way of doing it?

Thanks and best regards, Robert

set it in a global or javascript variable for later reading.

Hello Johan

Thanks for your reply. I just thought, because it’s the special command showFormInDialog, one would expect the calling form to get the result of the dialog (form) button pressed, because that’s what a dialog form is for, isn’t it? Or am I missing something here?
BTW, the debugger still behaves very strange as desrcibed earlier in this thread, one has to stop at the calling command, otherwise the behaviour is very strange.

Best regards, Robert

jcompagner:
set it in a global or javascript variable for later reading.

That form in dialog is not something like the dialogs plugin.
Because what it does is up to the developer and you have to implement that.

Also opening a form in dialog and there going into the debugger again is really some thing tricky (underneath) because it is not one session again. There are suddenly 2 debug sessions.. Thats why it is a bit erratic.. Maybe we can see if this can be fixed a bit better but it is the way the javascript engine works.

My understanding from the old days of Servoy (early 2005 :) ) was that commands should not be added after a showFormInDialog call.

From this thread it appears to be a misunderstanding and would appreciate clarification as it will help to reduce the number of methods in a solution.

Thanks

Graham Greensall
Worxinfo Ltd

My understanding is that code is executed “to the end” for the first formInDialog that you show, but not for further dialogs that yu might open from the first.

the first call to showFormInDialog will block the method execution at that point. Until the dialog is closed. (then it runs furter)

patrick is right that at the moment if you show a form in a form in dialog (so you stack it) then currently the method doesn’t block because we don’t really show a new dialog but reuse the old one.

I hope that i can give you an option for this in 3.0 so that we do show a second or third dialog and the method will block.

johan

Hi All

jcompagner:
That form in dialog is not something like the dialogs plugin.
Because what it does is up to the developer and you have to implement that.

I understand that it’s different from the dialog plugin, but as the name implies, I assume it is used primarily (or exclusivly?) for dialogs. And as that, it’s up to the developer to put anything on this dialog, but at the end there is always an answer needed, something like Cancel or Save | Export or whatever. So to me, it would be welcome to be able to read back the buttons pressed. Or do others see it differently?

jcompagner:
Also opening a form in dialog and there going into the debugger again is really some thing tricky (underneath) because it is not one session again. There are suddenly 2 debug sessions.. Thats why it is a bit erratic.. Maybe we can see if this can be fixed a bit better but it is the way the javascript engine works.

Ok, thanks and best regards, Robert

Hi Johan,

just something I have noticed:

  1. Write a global method which opens a Form-in-dialog
  2. Write a global method in another module which calls the first method.
  3. Call this method from a form method, and the statements afterwards in the form method will execute straight away…

I can work around this by removing step 2… but I prefer to create black boxes to isolate logic

i don’t know exacty what you try to describe here.
Are you opening 2 forms in dialogs?
Is then the method running further where you don’t expect it?

just one dialog…
sorry maybe this one doesn’t belong in this thread.

Is the debugger not enabled in youre case?

Because if you have enabled the debugger then the form in dialog is not shown as modal. Because you maybe want to debug a script that is executed in that dialog.

If this is not the case if you have a reproduceable test case where a method runs further when showing the first dialog. Please make a sample of this and send it over.

johan

Hi Jan. Maybe it is the debugger. I created a test solution and it works fine…