KRL Scope Safari: Entity Variables
Note: For another perspective on KRL persistent variables I would highly recommend the Kynetx App A Day article Day 12 - Persistent Variables by Michael Grace.
Since the definitive authority is code, here is a KRL ruleset! There are three rules in this demo application. The first rule, Safari_Initialize displays a growl notification which includes a title, the current value of the entity variable and two html forms which enable the entity variable to mutated and cleared. The second rule, Safari_Respond_Submit processes the form submission to mutate (change) the entity variable. The last rule, Safari_Respond_Clear processes the form submission to clear the entity variable.
The value of the entity variable can be accessed inside of a prelude expression. In the prelude section of Safari_Initalize the value of safari_entity is accessed. Entity variables can be mutated in the postlude section of a rule. In the postlude section of Safari_Respond_Submit the value of the entity variable safari_entity is set to the value of newValue. And in the postlude section of Safari_Respond_Clear the entity variable safari_entity is cleared.
Now it's time to start the safari demo of persistent entity variables. You can follow along with the demo in another browser window by visiting http://kynetx.aculis.net/safari/entity.html. When this Kynetx ruleset is run for the first time the entity variable does not exist, and so it is set to the value "Just Born!".
The value of the entity variable can be changed by entering a new value into the text field.
After the Mutate button is clicked the current value of the entity variable is updated.
When the browser window is reload or a new window is opened the current value of the entity variable remains the same.
Clicking the Clear button will destory the entity variable.
Then when the browser window is reloaded, or a new window is opened, we are back at the beginning of this demo.
An extremely important point to note is that entity variables are tied to your browser session in much the same way as browser cookies. You can see this for yourself by running this demo in two separate browsers (e.g. Firefox & Chrome) or by running the demo on two separate computers. Simply running the demo in two separate Firefox windows on the same computer is not the same since the session is the same.
The Scope Safari continues next time when we look at the scope of Application persistent variables on the Kynetx platform.
Enjoy!
This entry was posted on Dec 21, 2010
, Tuesday, December 21, 2010 and is filed under kynetx,safari. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response.


















