Save changes popup when Switching tabs in VLF One
Posted: Tue Apr 04, 2017 12:19 am
Hello Forum!
I'm running into an issue with the web framework where I'm trying to stop the user from going to another tab in the command handler without saving their changes.
I've looked at using a method routine thats part of the command handler called uQueryCanClose but I can't get it to do exactly what I want.
http://docs.lansa.com/14/en/lansa048/Co ... 8_4830.htm
It doesn't seem to trigger on tab switches, just if you close the command handler window itself.
I saw in the doco that you can setup logic based on the reason code returned from the method, but it looks like I cant do that in the web
I turned on tracing to see what else is going on when I switch to a different tab and I notice that uTerminate runs.
So, i put in some catching logic when the user switches tabs, if something has changes go to uQueryCanClose through uTerminate.
But now I get a pop up from the browser that says the framework tried to destroy is still active. I don't want my users seeing this.
Also, a side effect i noticed when using uQueryCanClose is if the command handler detects it I can no longer close the command handler no matter what I do. Could be just my coding, not really sure at this point
Anyway, here is all the important bits from my command handler that listens for the changes.
Its all based on a generic CRUD handler tapping off of PSLMST (demo employee file).
Thanks forum!
I'm running into an issue with the web framework where I'm trying to stop the user from going to another tab in the command handler without saving their changes.
I've looked at using a method routine thats part of the command handler called uQueryCanClose but I can't get it to do exactly what I want.
http://docs.lansa.com/14/en/lansa048/Co ... 8_4830.htm
It doesn't seem to trigger on tab switches, just if you close the command handler window itself.
I saw in the doco that you can setup logic based on the reason code returned from the method, but it looks like I cant do that in the web
I turned on tracing to see what else is going on when I switch to a different tab and I notice that uTerminate runs.
So, i put in some catching logic when the user switches tabs, if something has changes go to uQueryCanClose through uTerminate.
But now I get a pop up from the browser that says the framework tried to destroy is still active. I don't want my users seeing this.
Also, a side effect i noticed when using uQueryCanClose is if the command handler detects it I can no longer close the command handler no matter what I do. Could be just my coding, not really sure at this point
Anyway, here is all the important bits from my command handler that listens for the changes.
Code: Select all
Mthroutine Name(uTerminate) Options(*REDEFINE)
* <your termination logic goes here>
* <your termination logic goes here>
* <your termination logic goes here>
If Cond(#Button_All.Enabled *EQ TRUE)
#SYS_WEB.Alert Caption("Called through uTerminate")
Invoke Method(#COM_OWNER.uQueryCanClose) Canbecancelled(False) Timeoutinprogress(False)
Endif
#PanelFields.RemoveAll
#KeyFields.RemoveAll
* Do any termination defined in the ancestor
#Com_Ancestor.uTerminate
Endroutine
Mthroutine Name(uQueryCanClose) Options(*REDEFINE)
If Cond(#Button_All.Enabled *EQ True)
#SYS_WEB.Alert Caption("Called through uQueryCanClose")
#SAVEMSGBOX.Show
Else
#COM_OWNER.uTerminate
Endif
Endroutine
Evtroutine Handling(#SAVEMSGBOX.Closed)
If Cond(#SAVEMSGBOX.Result *EQ YES)
* RUN THE SAVE LOGIC
#COM_OWNER.uSave
#SYS_WEB.Alert Caption("Logic Saved!")
* Otherwise, skip the save and load the next screen
Else
#Button_All.Enabled := False
#COM_OWNER.uTerminate
Endif
Endroutine
Thanks forum!