Let's say we have a very simple native Android app. It has two Forms. Form1 with a button that navigates to Form2, which in turn has an onNavigate action that displays an Alert.
When this application is run in the Volt MX Preview app, it works as expected. Pressing the button navigates to a different form and an alert message is shown. However, if the app is built locally or built online and published (binary build), the onNavigate action never gets called. I.e. pressing the button still navigates to another form, but nothing else happens. Using another action, such as preShow works flawlessly.
I've also been wondering, what the exact differences between the various actions of forms are. For example, is onMapping called before or after onNavigate? I presume preShow is executed after the former two. Also, when are onHide and onDestroy called?
Thank you very much for your input!
Cheers
P.S.: I'm using Volt MX Iris version 9 SP 2 FP 38. I have tested this on Android 5.1, 10.0 and 11.0
Hi Marcel, regarding the form events, here is a link that helps illustrate the form lifecycle:
https://opensource.hcltechsw.com/volt-mx-docs/docs/documentation/Iris/iris_widget_prog_guide/Content/Form.html
The diagram does not mention it, but the onNavigate event is called prior to the onInit. The order of events when navigating to a form are:
onNavigate
onInit
preShow
onMapping
postShow
This means that any sort of UI changes or updates need to be done after onNavigate - any attempt to try and reference a widget or other variable declared in the form's controller in the onNavigate event will result in a null reference exception. The onNavigate should be used for managing any context variables being passed from the prior form (if they are being used).
Regarding the issue with the event not firing, I was able to reproduce this by defining a simple action of a code snippet to call voltmx.print() in the onNavigate event editor and I did not see it fire. I would suggest logging a Support case on that. However, I did find that a workaround is to manually define the function event in the controller code and then have the onNavigate event editor use an Invoke Function action to call the onNavigate function:
[begin code snip]
onNavigate : function(navData, isBackNavigation)
{
voltmx.print("####### frmNavDemo2.onNavigate() start");
voltmx.print("####### frmNavDemo2.onNavigate() end");
},
[end code snip]
Hope this helps!
Cheers,
Gunndarr