Take for example this sample application including a refresh-button, a two textfields and a frame. The frame contains a textfield and a button. When the button within the frame is pressed, the value of the text field within the frame is passed to the QAFE application data store. By pressing the refresh button, the text fields will be filled in based on the value within the frame.
The code snippet below describes how to store the values into either the global store (application-wide) or the user store (only within a window). An ApplicationContext needs to be initiated to know which application store to use. Two dependencies (qafe-core and qafe-presentation) need to be imported. See Github for more information.
String windowSessionId = (String) parameters.get("windowSessionId");
String inputField = (String) parameters.get("inputField");
ApplicationContext qafe = getApplicationContext();
String globalDataStoreId = EventItemExecuteHelper.generateLocalStoreId(windowSessionId, qafe, null);
// helloWorld is the window ID specified in the QAML-file
String windowDataStoreId = EventItemExecuteHelper.generateLocalStoreId(windowSessionId, qafe, "helloWorld");
// Will be stored as a global variable
ApplicationLocalStore.getInstance().store(globalDataStoreId, "dummyKey", "dummyValue");
// Will be stored as a user variable
ApplicationLocalStore.getInstance().store(windowDataStoreId, "inputField", inputField);
In this example, value “dummyValue” is stored in the global store with name “dummyValue”. The input variable is available in the user store with name “inputField”. These values can now be used in other events.
Thank you for reading this blog! More technical details and additional code snippets can be found on Github.
Blog by: Arvind Mohabir