0

Fileupload and event processing thread

asked 2009-04-15 09:36:27 +0800

paoloa gravatar image paoloa
24 1 2

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

delete flag offensive retag edit

13 Replies

Sort by ยป oldest newest

answered 2009-07-06 06:24:14 +0800

anupriya gravatar image anupriya
6

Hi robbiecheng,
Can u send me a sample code to upload file of any format in zk?

link publish delete flag offensive edit

answered 2009-07-09 10:46:57 +0800

robbiecheng gravatar image robbiecheng
1144 2
http://robbiecheng.sys-co...

Hi Anupriya,

Please refer to this example.

/robbie

link publish delete flag offensive edit

answered 2009-08-10 16:13:55 +0800

totocutugno gravatar image totocutugno
6

Same error than Swallow...

Any suggestions?
Thanks a lot

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-04-15 09:36:27 +0800

Seen: 1,743 times

Last updated: Aug 10 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More