0

我有一个工具栏,当我单击任何正在创建选项卡的项目时,我现在正在使用大量项目。类似于此代码的内容

public static void openNewTab(String title, String path, Tabbox mainTab) {
    Tab tab = new Tab(title);
    tab.setClosable(true);
    tab.setParent(mainTab.getTabs());
    Tabpanel tabpanel = new Tabpanel();
    Include include = new Include(path);
    include.setParent(tabpanel);
    tabpanel.setParent(mainTab.getTabpanels());
    mainTab.setSelectedTab(tab);
}

现在我想要获取所选选项卡的 ViewModel 当 ZUL 中的任何 Ctrl 键按下时...我有这个

@Wire("#mainTab")
Tabbox mainTab;
   Tab tab = mainTab.getSelectedTab( );

可以从 selectedTab 变量中获取 ViewModel 吗?

我正在这样做

Include include = new Include(path);
include.setParent(tabpanel);
Object object = include.getAttribute("viewModel");

现在对象给出 null 我们可以从这里获取 ViewModel,而我在这里包含 ZUl 吗?

4

1 回答 1

1

似乎 id 是获取 vm 的属性名称,请参见zkfiddle 的示例

顺便说一句,“binder”是获取binder的属性名,更多信息请参考binder的源代码

您也可以尝试使用 Component.getAttributes 来获取属性映射并检查其中的所有属性,请参阅Javadoc:Component#getAttributes

于 2013-02-21T13:16:18.887 回答