Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mvvm ZK:在Client.showNotification中显示绑定值_Mvvm_Zk - Fatal编程技术网

Mvvm ZK:在Client.showNotification中显示绑定值

Mvvm ZK:在Client.showNotification中显示绑定值,mvvm,zk,Mvvm,Zk,我正在使用MVVM aproach处理一个ZK项目,我试图做的是显示@bind(each.info)值的通知,但它似乎不适合我,以下是我到目前为止所做的 <div width="59%" style=" float: left !important;" apply="org.zkoss.bind.BindComposer" viewModel="@id('menu') @init('ma.schlemmer.headerbar.mainMenu')"> <hl

我正在使用MVVM aproach处理一个ZK项目,我试图做的是显示@bind(each.info)值的通知,但它似乎不适合我,以下是我到目前为止所做的

<div width="59%"  style=" float: left !important;" apply="org.zkoss.bind.BindComposer"
  viewModel="@id('menu') @init('ma.schlemmer.headerbar.mainMenu')">


    <hlayout children="@bind(menu.listMenu)">
            <template name="children">
                     <a  iconSclass="@bind(each.icon)"  href="@bind(each.link)" autag="@bind(each.info)" onRightClick='Clients.showNotification("@bind(each.info)" ,"warning",this.self,"after_center",1000)'></a>
             </template>
     </hlayout>
</div>


谢谢

您可以使用ZK命令来完成此操作。您应该得到您想要的结果,如下所示:

<div width="59%"  style=" float: left !important;" apply="org.zkoss.bind.BindComposer"
    viewModel="@id('menu') @init('ma.schlemmer.headerbar.mainMenu')">


<hlayout children="@bind(menu.listMenu)">
    <template name="children">
        <a  iconSclass="@bind(each.icon)"  href="@bind(each.link)" autag="@bind(each.info)"
            onRightClick="@command('showInfo', obj=each, comp=self)"></a>
         </template>
 </hlayout>
您没有提供足够的代码,因此我无法测试确切的情况,但基本上您需要将每个对象(我猜这类似于ListMenu对象)和组件传递给命令。然后,您可以轻松地显示通知

致以最良好的祝愿, 奥斯瓦尔达斯

@Command
public void showInfo(@BindingParam("obj") ListMenu listMenu, @BindingParam("comp") Component comp) {
    Clients.showNotification(listMenu.getInfo(),"warning",comp,"after_center",1000);
}