2014-05-23 47 views
1

即時通訊工作在使用MVVM aproach的ZK項目上,我試圖做的是顯示@bind(each.info)值的通知,但似乎不適用於我,這是迄今爲止我所做的。ZK:在Client.showNotification中顯示綁定值

<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> 

,並感謝您

回答

1

你可以做到這一點使用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> 

那麼這個命令添加到您的視圖模型:

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

您沒有提供足夠的代碼,所以我不能老是測試確切的情況,但基本上你需要傳遞每個對象(我猜是像ListMenu對象)和組件到命令。然後你可以很容易地顯示通知。

最好的問候, Osvaldas

+0

THX ..它工作得很好:) –

+0

我真的很高興幫助,祝你好運! :) – Osvaldas