-
Jan SchroederHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the online course Advanced (320)1 year ago #40645
Hello dear community,
I currently have the problem that the global variables are “deleted” when I go through the module load/unload mechanism.
Is there any setting that needs to be configured differently?The content of
sap.ui.getCore().getModel(“variableHolder”).getProperty(“/”)
is just an empty array after I am back in my app.Best regards
Jan Schroeder- This topic was modified 1 year ago by Jan Schroeder.
Andreas DallnerHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the online course Advanced (320)Has successfully completed the Intermediate CertificationHas successfully completed the Advanced Certification1 year ago #40670::Hi Jan,
the variables of your module are stored in module context -> If you unload the module the context is destroyed as well. Values are stored in sap.ui.getCore().byId(“MODULENAME”).getModel(“variableHolder”).getProperty(“/”).
If you want to keep the values in app context you have to send the values via interface to the app and store it in the apps variables.
We do not recommend to reading/write data directly to the apps variable holder to have consistent api usage via the modules interfaces.
Kind regards,
Andreas- This reply was modified 1 year ago by Vitali Kurdasov. Reason: replaced "getId(" with "byId("
Vitali KurdasovHas successfully completed the online course Intermediate (200)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the Intermediate CertificationJan SchroederHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the online course Advanced (320)1 year ago #40678Vitali KurdasovHas successfully completed the online course Intermediate (200)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the Intermediate Certification1 year ago #40679::Hi,
I just would like to add the best practice:
It has certain advantages if you only use the modul-interfaces to get or set variables from the application to the module. The big advantage with this way is that you have a predefined and controlled way to access a specific variable inside a module. An access to those module-variables with the above mentioned “sap.ui.getCore()…”-call could lead to uncontrolled side-effects which makes it very hard to debug if needed.
You must be logged in to reply to this topic.