Reputation: 1587
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
Upvotes: 2
Views: 8425
Reputation:
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").
Upvotes: 1
Reputation: 6173
The getFellow() method can be used on ZK's component. Users can get access the component by it's ID
myWindow.getFellow("label_1");
if you're using ZK MVC way on your application.
you can save your **"composer" into the desktop, then you can access any part of the page.
Upvotes: 1