On This Page
advertisement

This page is part of the ORA Technical Notes series. it is not necessary for most users to read, understand, or retain the information on this help page. It is provided for power users and other people who are interested in (mostly technical) details.

ORA's implementation is constantly changing and the details in this Technical Note may not be up-to-date.

Scope

The two forms of the Assignment reference are [=:...] and [==:...]. They share most of their implementation. The only difference is where the name and value are stored. The storage location determines their scope.

For temporary variables created by [=:...], the name and value are stored in a local array within the template processor. The template processor discards that array when it finishes processing the template.

For persistent variables created by [==:...], the name and value are stored in a "user updated" array that conceptually belongs to the current page. That's why the values persist through Control Panel updates but do not persist when you refresh the page in the browser. The variables are accessible from any Text Template or Auto Type Template that is evaluated after the persistent variable is created.

The "user updated" array is shared by Edit Field (alt-click), Add Field, and persistent variables. To find a variable or Field value, the template processor looks first in its local array, then in the "user updated" array, and finally in the original values extracted from the page, and uses whichever value it finds first.

User updates have to be stored separately from the original values. Otherwise, user updates would not survive a panel refresh because values extracted from the original repository data would overwrite user updates.

You don't have to remember all that, but it might help you predict what will happen in various scenarios.

Text Templates

Text Templates are essentially a hybrid of Fields and persistent variables and that creates a side-effect you might not expect.

Let's assume you have a Text Template named "Test" and its value is "Luigi". The template definition doesn't really matter. I used a literal to keep the example simple.

If you alt-click on the value in the Control Panel and update it to "Antonio", the alt-click update won't appear to work! The issue is, after ORA does the alt-click assignment, it refreshes the Control Panel, and the Text Template is processed. The Text Template label and value replace any existing value, including the one in the user values array. Whatever value the user keyed is lost.

Typically, I think users want the Text Template to be processed to reproduce the result. Of course, there may be cases where the user wants a hand-entered value to persist. While one might argue that user edits should always have priority, there's no good way to do that without causing other issues.

Here's how to use conditional alternatives to get around this challenge:

<[Test]|Luigi>

With that definition for a Text Template, ORA will use the existing value (via [Test]). If no value has been set yet, the template will set the value to "Luigi". If the user has edited the Field via alt-click, or if a prior template set a persistent variable, [Test] will have a value. Otherwise, it will not.