0

Trouble with Fileupload

asked 2009-11-10 00:54:42 +0800

sachinbhave gravatar image sachinbhave
18 1 1

updated 2009-11-10 03:38:37 +0800

Hi

I am having trouble getting the Fileupload to work. I have implemented Fileupload as per the API docs but on clicking the upload button after selecting a file, the Fileupload.get() method always returns null.

I tried uploading a larger size file and then the progress bar pops up but it vanishes just as soon and again get() returns a null.

I am on a linux box and using Firefox. Everything is default - grails jetty and in mem db. I also tried the embedded version instead of a separate dialog with the same result.

Thanks in advance

P.S. let me also add that i am getting no error or exception

delete flag offensive retag edit

16 Replies

Sort by ยป oldest newest

answered 2009-11-10 21:59:31 +0800

tmillsclare gravatar image tmillsclare
799 2 5 30

Hey sachinbhave,

Can you please provide a sample zul file and code. In addition what version of ZK are you using?

Thanks,
Tim

link publish delete flag offensive edit

answered 2009-11-11 00:19:04 +0800

sachinbhave gravatar image sachinbhave
18 1 1

i am using exactly the same code as in the Fileupload API doc example :

<window title="Fileupload Demo" border="normal">
<image id="image"/>
<button label="Upload">
<attribute name="onClick">{
Object media = Fileupload.get(); <--------------------------------------------------------------------- media is always null after selecting a file and clicking upload
if (media instanceof org.zkoss.image.Image)
image.setContent(media);
else if (media != null)
Messagebox.show("Not an image: "+media, "Error",
Messagebox.OK, Messagebox.ERROR);
}
</attribute>
</button>
</window>

I am using ZK 0.7.4 with grails 1.1.1

Thanks
Sachin

link publish delete flag offensive edit

answered 2009-11-11 19:09:49 +0800

tmillsclare gravatar image tmillsclare
799 2 5 30

Hey sachinbhave,

I presume you mean ZK Grails is version 0.7.4? If that is the case then the ZK version included is 3.6.2. I just tried your code soley with ZK 3.6.2 and it worked fine, could you please just try to create a new ZK project using version 3.6.2 without ZK Grails and let me know whether that is working. If it does then we can focus on an issue with ZK Grails!

Thanks,
Tim

link publish delete flag offensive edit

answered 2009-11-12 06:24:52 +0800

sachinbhave gravatar image sachinbhave
18 1 1

hey Tim

Yes I meant ZK Grails version 0.7.4 and did what you suggested. Its working fine without ZK Grails, i tried out a quick demo.

Thanks
Sachin

link publish delete flag offensive edit

answered 2009-11-18 04:52:25 +0800

Bobzk gravatar image Bobzk
444 1 8

You might want to try the fileupload on a "clean" project. I have found that if you use Zeta (and effectively you end up building a spring/hibernate project), Fileupload does not work in that project. Fileupload is then no longer modal and returns to the next java statement straight away.

I am guessing the event processing model changes. Perhaps Grails (I have not used this) also changes the event processing model?

This is on ZK 3.6.3.

link publish delete flag offensive edit

answered 2009-11-18 09:54:29 +0800

Bobzk gravatar image Bobzk
444 1 8

From the reference manual where it refers to -

To disable the use of the event processing threads, you have to specify the following content in

WEB-INF/zk.xml.
<system-config>
<disable-event-thread/>
</system-config>

File Upload

The file upload dialog is no longer applicable. Rather, you shall use the fileupload
component instead. The fileupload component is not a modal dialog. Rather, it is placed
inline with other components. Refer to the fileupload Component section for more
information.
<fileupload onUpload="handle(event)"/>

link publish delete flag offensive edit

answered 2009-12-04 17:10:54 +0800

lucassimao gravatar image lucassimao
42 4

I have problems with fileupload, too. I'm using ZkGrails plugin. Some solution?

link publish delete flag offensive edit

answered 2009-12-09 23:47:26 +0800

sachinbhave gravatar image sachinbhave
18 1 1

hey bobzk

Thank you for your suggestions.

I tried disabling the event processing in zk and then tried using fileupload component on a clean project.
Unfortunately I get the same result as before, that the event.media is null. I suppose it has something to do
with the grails plugin.

link publish delete flag offensive edit

answered 2009-12-12 13:55:32 +0800

chanwit gravatar image chanwit
93 1

Hi all,

Adding the line: static excludes = ['/zkau/*']
to your UrlMappings.groovy, which can be found under ./grails-app/conf/
would solve the problem.

class UrlMappings {
static excludes = ['/zkau/*']
static mappings = {
...
}
}

I have tested this with ZKGrails 0.7.6.

Cheers,

Chanwit

link publish delete flag offensive edit

answered 2009-12-17 23:17:09 +0800

sachinbhave gravatar image sachinbhave
18 1 1

hey chanwit,

Thank you very much for your solution. Fileupload is working fine now with the exclude rule.

Cheers,
Sachin

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-11-10 00:54:42 +0800

Seen: 3,564 times

Last updated: Mar 07 '13

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