-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
I am trying to implement image uploading for a form in my application. Everything works except a small detail: when I call a method on my ViewModel, it doesn't seem to trigger the @NotifyChange behaviour I am expecting. Here is the relevant part of my zul:
<groupbox id="insertForm" form="@id('logo') @load(vm.selected) @save(vm.selected, before='update') @save(vm.selected, before='delete')"> <caption label="Insert/edit Logo" /> Image: <textbox id="strpath" readonly="true" value="@load(logo.path)" /> <button id="path" upload="true" onUpload="vm.setImage(event.media)" label="Upload image" /> [...] </groupbox>
And here is the relevant part of setImage:
@NotifyChange("selected") public void setImage(Media file) { if (file instanceof Image) { this.image = (Image)file; getSelected().setPath("/path/to/images/" + image.getName()); } }
Now I would expect the textbox to display my new path as soon as the file is uploaded and the function is called, but it doesn't seem to be working... What am I missing? I am pretty new to ZK and the MVVM pattern, so I probably went wrong somewhere... Any help would be appreciated!
I guess you need to use ZK6 command not inline Java for your event handler. Something like this:
onUpload="@command('updateImage')" @Command @NotifyChange(...) public void updateImage(@ContextParam(ContextType.TRIGGER_EVENT) UploadEvent event) { ... }
Asked: 2012-04-27 14:51:04 +0800
Seen: 278 times
Last updated: Apr 28 '12