Wire Variables

From Documentation
Revision as of 09:07, 26 November 2010 by Tomyeh (talk | contribs) (→‎ID Space)

Wiring Sequence

GenericForwardComposer will wire members defined in the composer. Here is the sequence:

  1. It searches any setter if its name matches any of the following
    1. Any fellow with the same name (Component.getFellow(String))
    2. Any variable defined in Page.addVariableResolver(VariableResolver) with the same name
    3. Any variable defined in zscript with the same name
    4. Any implicit object with the same name
  2. Then, it searches any field to see if it matches any fellow, any variable,... the same as the above.

zscript and Variable Resolver

By default, variables defined in both zscript and variable resolvers will be checked[1]. There might be some performance penalty if you have too much zscript code, or your variable resolver is too slow.

You could turn them off by passing false to the second and third argument of GenericForwardComposer.GenericForwardComposer(char, boolean, boolean):

public class MyComposer extends GenericForwardComposer {
    public MyComposer() {
        super('$', false, false);
    }
}

  1. It will be default to false in ZK 6 for better performance.

ID Space

For components that are inside of another ID space, you could use id1$id2$id3 to access it. More precisely, it will cause GenericForwardComposer to look for id1 in the same ID space as the applied component, and then look for, if found and it is another ID space, id2, and so on. For example, you could find the textbox by inner$input.

<window apply="foo.MyComposer">
   <window id="inner">
        <textbox id="input"/>
...

Here is another example: suppose have two ZUL files:

Main file Included file - includeme.zul
<window id="mywindow" apply="MyComposer">
    <include id="i" src="includeme.zul" />
</window>
   <textbox id="username" />

Before ZK 5 you could not access the textbox "username" from "MyComposer", however now you can. To do this you need to specify:

<syntax lang="java"> public class MyComposer extends GenericAutowireComposer {

        Textbox id_of_include$control_id;
       ...

} </syntax>

In the case of our example this would be:

<syntax lang="java"> public class MyComposer extends GenericAutowireComposer {

        Textbox i$username;
       ...

} </syntax>

Version History

Last Update : 2010/11/26

Version Date Content
     



Last Update : 2010/11/26

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.