-
New Feature
-
Resolution: Unresolved
-
Normal
-
None
-
None
The variable resolver registered with <?variable-resolver?> will remain in the page. It is important for some applications, such as data binding, since variables will be retrieved later (after the page is initialized).
However, some variable resolver is used only for providing variables that are required only in the rendering phase. It is better to be removed automatically after the page is rendered. Otherwise, if the same page has been created recursively, two or more instances of the same variable resolvers will be added and remained in the page.
For example,
//in a.zul
<?variable-resolver class="X"?>
<zscript>
execution.createComponents("a.zul"...)
</zscript>
${v}
Since a.zul is rendered twice (recusively), two instances of X are added to page. Thus, if both instances resolves a variable, say, v, then ${v} is always an instance returned by the send instance of X, no matter it is called in the first rendering of a.zul or the second rendering.
A possible solution: X implements an additional interface called Temporary, and then ZK remove it automatically if it found Temporary is implemented:
class X implements VariableResolver, Temporary {
...