I am passing a bunch of tabs from a zul file to a java file like so:
tabs.zul
<tabs>
<tab id="tab1" label="Tab1"> </tab>
<tab id="tab2" label="Tab2"> </tab>
</tabs>
<zscript>
testTabs = new TestTabs();
Tab[] tabs = {tab1, tab2}
testTabs.registerTabs(tabs)
</zscript>
TestTabs.java
public class TestTabs {
....
private HashMap<String,Tab> tabMap;
void registerTabs (Tab[] tabs) {
this.tabMap = new HashMap<String,Tab>();
for (Tab t: tabs) {
this.tabMap.put(t.getId(),t);
}
}
if(condition) {
tabMap.get("tab1").setVisible(true);
tabMap.get("tab2").setVisible(true);
}
}
Now, I guess using Hashmaps to access a tab is a roundabout way. Using a getFellow(String id) method to access a tab would be much simpler, right ? But, I am not sure how to implement that. Can someone help me with this?
Thanks, Sony
There are several ways to do that:
<window id="myWindow" use="package.to.your.ClassThatExtendsWindow">
<!-- your tabs go here -->
</window>
Tab tab1 = (Tab) this.getFellow("tab1");
<window id="myWindow" apply="package.to.your.ClassThatExtendsGenericForwardComposer">
<!-- your tabs go here -->
</window>
private Tab tab1;
and you can use it right away. Note the differente bewtween the use and apply keywords. If you use the second approach, make sure that the name of your variable matches the id of your component ("tab1").