Hi, I have a code like this in a zul file:
<listbox>
<listitem>
<listcell tooltip="tooltip${each.code}">
<popup id="tooltip${each.code}">
<image src="...remove.gif">
<custom-attributes targetDto="${each}"/>
</image>
</popup>
</listcell>
<listcell label="${each.name}"/>
</listitem>
</template>
</listbox>
I want to handle the click on the "image", remove some stuff and then refresh the listbox. I know one way to do this is to have a custom renderer for the whole listbox and then addListener on the image. Is there other way to do it, for example to use forward like:
forward="onClick=onRemoveImageClick"?
Or even directly call a method of the widget's controller/composer:
onClick="widgetControllerBean.removeThing()"
Hi,
there are a few things:
we discourage using MVVM while it turned out to have performance issues for more complex widgets
if you want to use MVVM declare the controller:
<controller class="my.apckage.MyController" id="myModel"/>
now you can access the Controller via myModel vairable
use onClick="@command('someMethod')" to trigger methods on the controller; the methods must be annotated with org.zkoss.bind.annotation.Command
Cheers, Wojtek
This is what worked for me:
<listbox id="listboxId" >
<template name="model">
<listitem>
<listcell tooltip="tooltip${each.code}">
<popup id="tooltip${each.code}">
<image src="...remove.gif" forward="onClick=listboxId.onDeleteSomething"/>
</popup>
</listcell>
<listcell label="${each.name}"/>
</listitem>
</template>
</listbox>
On the controller:
@ViewEvent(componentID = "listboxId", eventName = "onDeleteSomething")
public void listboxOnDelete(final ForwardEvent event)
Add a comment