File upload using Spring configuration

View: New views
4 Messages — Rating Filter:   Alert me  

File upload using Spring configuration

by tmclaugh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey all,

Has anyone done DWR file uploads using the Spring applicationContext based configuration?  I see that there is a FileConverter in 3.x but I'm unsure how to take advantage of it.  I don't have any Spring multipart stuff in my web.xml, which I see has caused some grief with others.

I've got a method which takes a File.  I've also tried some other types that the literature out there indicates can be used.

public void upload(File file) throws IOException {...}
//public void upload(byte[] bytes) throws IOException {...}
//public void upload(InputStream in) throws IOException {...}
//public void upload(FileTransfer file) throws IOException {...}

And in my applicationContext I've got the bean declared.

<bean name="myBean" class="MyClass" autowire="byType">
    <dwr:remote javascript="Facade">
        <dwr:include method="upload" />
    </dwr:remote>
</bean>

And then there's some client code.

<input type="file" id="upload"/>
<button onclick="Facade.upload(dwr.util.getValue('file'));">Upload</button>

When I do an upload I get this output:
WARN Call:205 - No methods called class MyClass.upload' are applicable for the passed parameters.

My hunch is I need to register FileConverter in my <dwr:configuration>, but I'm stumped on how.  Any ideas?  My next path to get this working is to try and do it programmatically, but that seems like a hack.  

Thanks,
Tom

Re: File upload using Spring configuration

by davidmarginian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would suggest downloading the war and looking at the upload example, although not integrated with Spring it should help.  

On Fri, Oct 16, 2009 at 11:41 AM, tmclaugh <tom.mclaughlin@...> wrote:

Hey all,

Has anyone done DWR file uploads using the Spring applicationContext based
configuration?  I see that there is a FileConverter in 3.x but I'm unsure
how to take advantage of it.  I don't have any Spring multipart stuff in my
web.xml, which I see has caused some grief with others.

I've got a method which takes a File.  I've also tried some other types that
the literature out there indicates can be used.

public void upload(File file) throws IOException {...}
//public void upload(byte[] bytes) throws IOException {...}
//public void upload(InputStream in) throws IOException {...}
//public void upload(FileTransfer file) throws IOException {...}

And in my applicationContext I've got the bean declared.

<bean name="myBean" class="MyClass" autowire="byType">
   <dwr:remote javascript="Facade">
       <dwr:include method="upload" />
   </dwr:remote>
</bean>

And then there's some client code.

<input type="file" id="upload"/>
<button onclick="Facade.upload(dwr.util.getValue('file'));">Upload</button>

When I do an upload I get this output:
WARN Call:205 - No methods called class MyClass.upload' are applicable for
the passed parameters.

My hunch is I need to register FileConverter in my <dwr:configuration>, but
I'm stumped on how.  Any ideas?  My next path to get this working is to try
and do it programmatically, but that seems like a hack.

Thanks,
Tom
--
View this message in context: http://www.nabble.com/File-upload-using-Spring-configuration-tp25929511p25929511.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Re: File upload using Spring configuration

by tmclaugh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, just stepping back and looking at the example and thinking it through from the beginning helped me figure out my problem.  It was as simple as having the HTML, of all things, wrong.  Turns out file uploads work great on the spring side too.

davidmarginian wrote:
I would suggest downloading the war and looking at the upload example,
although not integrated with Spring it should help.

Re: File upload using Spring configuration

by davidmarginian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Tom.

On Fri, Oct 16, 2009 at 1:16 PM, tmclaugh <tom.mclaughlin@...> wrote:

Yes, just stepping back and looking at the example and thinking it through
from the beginning helped me figure out my problem.  It was as simple as
having the HTML, of all things, wrong.  Turns out file uploads work great on
the spring side too.


davidmarginian wrote:
>
> I would suggest downloading the war and looking at the upload example,
> although not integrated with Spring it should help.
>

--
View this message in context: http://www.nabble.com/File-upload-using-Spring-configuration-tp25929511p25930838.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...