-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm trying to use Fileupload.get() to upload an image from a detail-edit section of a web page
generated with the ZETA form builder,
which I have modified, trying to adapt the code found in the Fileupload example of the zkdemo application.
The page manages an "album" table, representing a collection of audio files.
The image is the cover image of the album.
In album.ZUL I have:
<button id="imageUpload" label="Upload" />
In AlbumControllerBase.java:
@Resource protected Button imageUpload; @Resource protected Vbox image; ........ @EventHandler("imageUpload.onClick") public void doImageUpload(Event event) { try { Media media = Fileupload.get(); if (media instanceof org.zkoss.image.Image) { org.zkoss.zul.Image image = new org.zkoss.zul.Image(); image.setContent((org.zkoss.image.Image)media); image.setParent(this.image); } else if (media != null) { Messagebox.show("Not an image: " + media, "Error", Messagebox.OK, Messagebox.ERROR); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
When I press the image upload button, i get the following exception:
15-Apr-2009 11:02:50 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1108 SEVERE: >>org.zkoss.zk.ui.SuspendNotAllowedException: Event processing thread is disabled >> at org.zkoss.zul.Window.doModal(Window.java:539) >> at org.zkoss.zul.Fileupload.get(Fileupload.java:335) >> at org.zkoss.zul.Fileupload.get(Fileupload.java:300) >> at org.zkoss.zul.Fileupload.get(Fileupload.java:233) >> at org.zkoss.zul.Fileupload.get(Fileupload.java:187) >>...
Should not be event processing thread enabled by default?
Anyway, I tried to manually enable the event thread by adding the following lines
at the beginning of the try block in the event handler method:
Desktop desktop = Executions.getCurrent().getDesktop(); desktop.getWebApp().getConfiguration().enableEventThread(true);
and i got the following exception instead:
15-Apr-2009 11:21:11 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1108 SEVERE: >>org.zkoss.zk.ui.UiException: This method can be called only in an event listener, not in paging loading. >> at org.zkoss.zk.ui.impl.UiEngineImpl.wait(UiEngineImpl.java:1246) >> at org.zkoss.zk.ui.Executions.wait(Executions.java:347) >> at org.zkoss.zul.Window.enterModal(Window.java:619) >> at org.zkoss.zul.Window.doModal(Window.java:555) >> at org.zkoss.zul.Fileupload.get(Fileupload.java:335) >>...
Same error than Swallow...
Any suggestions?
Thanks a lot
Asked: 2009-04-15 09:36:27 +0800
Seen: 1,743 times
Last updated: Aug 10 '09