You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by jf nuzbit <jf...@gmail.com> on 2007/05/13 21:51:47 UTC

[s2] ajax multipart form submission

Hello,

Has anyone managed to get a multipart/form-data submission working with the
ajax theme?
This is what I've got so far:

<s:form namespace="/nodecorate" action="myaction"
enctype="multipart/form-data" method="post">
    <s:file value="image" name="image"></s:file>
    <s:textfield value="title" name="item.title"/>...

    <s:submit theme="ajax" targets="useritems" value="submit"></s:submit>
</s:form>

Which looks like it's almost working but the target div updates with
'[object HTMLDocument]' and the action never gets invoked.
If i remove the s:file element from the form then everything works as
expected with the div updating with the result from the action.

This looks to me like a problem with dojo as opposed to Struts2, I'm using
version 2.0.6 by the way.
Has anyone else encountered this or have any ideas?

Any help appreciated.
Thanks,

Jack

Re: [s2] ajax multipart form submission

Posted by Musachy Barroso <mu...@gmail.com>.
We don't have an attribute to specify the "transport" for the the bindArgs.
I logged a Jira ticket for it:

https://issues.apache.org/struts/browse/WW-1925

thanks for reporting back :)
musachy

On 5/15/07, jf nuzbit <jf...@gmail.com> wrote:
>
> Here is how to make it work using dojo:
>
> The form:
>
> <form id="myform" action="nodecorate/myaction.action"
> enctype="multipart/form-data" method="post">
>        <s:file name="myfile"></s:file>
>        <input type="button" onclick="sendIt(); return false;">
> </form>
>
> The javascript:
>
> function sendIt(){
>     var bindArgs = {
>         transport: "IframeTransport",
>         formNode: document.getElementById("myform"),
>         mimetype: "text/html",
>         load: function(type, data, evt){
>             document.getElementById("mydiv").innerHTML =
> data.firstChild.innerHTML;
>         }
>     };
>     var request = dojo.io.bind(bindArgs);
> }
>
> The div with id 'mydiv' will then get updated with the response from the
> action.
>
> Jack
>
>
> On 5/13/07, Musachy Barroso <mu...@gmail.com> wrote:
> >
> > Try to get it to work with dojo first, no struts involved. I think there
> > has
> > been a couple of posts about this in the mailing list. Let us know if
> you
> > get it to work as it would make a good FAQ :)
> >
> > musachy
> >
> > On 5/13/07, jf nuzbit <jf...@gmail.com> wrote:
> > >
> > > Hello,
> > >
> > > Has anyone managed to get a multipart/form-data submission working
> with
> > > the
> > > ajax theme?
> > > This is what I've got so far:
> > >
> > > <s:form namespace="/nodecorate" action="myaction"
> > > enctype="multipart/form-data" method="post">
> > >     <s:file value="image" name="image"></s:file>
> > >     <s:textfield value="title" name="item.title"/>...
> > >
> > >     <s:submit theme="ajax" targets="useritems"
> > value="submit"></s:submit>
> > > </s:form>
> > >
> > > Which looks like it's almost working but the target div updates with
> > > '[object HTMLDocument]' and the action never gets invoked.
> > > If i remove the s:file element from the form then everything works as
> > > expected with the div updating with the result from the action.
> > >
> > > This looks to me like a problem with dojo as opposed to Struts2, I'm
> > using
> > > version 2.0.6 by the way.
> > > Has anyone else encountered this or have any ideas?
> > >
> > > Any help appreciated.
> > > Thanks,
> > >
> > > Jack
> > >
> >
> >
> >
> > --
> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

Re: [s2] ajax multipart form submission

Posted by jf nuzbit <jf...@gmail.com>.
Here is how to make it work using dojo:

The form:

<form id="myform" action="nodecorate/myaction.action"
enctype="multipart/form-data" method="post">
       <s:file name="myfile"></s:file>
       <input type="button" onclick="sendIt(); return false;">
</form>

The javascript:

function sendIt(){
    var bindArgs = {
        transport: "IframeTransport",
        formNode: document.getElementById("myform"),
        mimetype: "text/html",
        load: function(type, data, evt){
            document.getElementById("mydiv").innerHTML =
data.firstChild.innerHTML;
        }
    };
    var request = dojo.io.bind(bindArgs);
}

The div with id 'mydiv' will then get updated with the response from the
action.

Jack


On 5/13/07, Musachy Barroso <mu...@gmail.com> wrote:
>
> Try to get it to work with dojo first, no struts involved. I think there
> has
> been a couple of posts about this in the mailing list. Let us know if you
> get it to work as it would make a good FAQ :)
>
> musachy
>
> On 5/13/07, jf nuzbit <jf...@gmail.com> wrote:
> >
> > Hello,
> >
> > Has anyone managed to get a multipart/form-data submission working with
> > the
> > ajax theme?
> > This is what I've got so far:
> >
> > <s:form namespace="/nodecorate" action="myaction"
> > enctype="multipart/form-data" method="post">
> >     <s:file value="image" name="image"></s:file>
> >     <s:textfield value="title" name="item.title"/>...
> >
> >     <s:submit theme="ajax" targets="useritems"
> value="submit"></s:submit>
> > </s:form>
> >
> > Which looks like it's almost working but the target div updates with
> > '[object HTMLDocument]' and the action never gets invoked.
> > If i remove the s:file element from the form then everything works as
> > expected with the div updating with the result from the action.
> >
> > This looks to me like a problem with dojo as opposed to Struts2, I'm
> using
> > version 2.0.6 by the way.
> > Has anyone else encountered this or have any ideas?
> >
> > Any help appreciated.
> > Thanks,
> >
> > Jack
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>

Re: [s2] ajax multipart form submission

Posted by Musachy Barroso <mu...@gmail.com>.
Try to get it to work with dojo first, no struts involved. I think there has
been a couple of posts about this in the mailing list. Let us know if you
get it to work as it would make a good FAQ :)

musachy

On 5/13/07, jf nuzbit <jf...@gmail.com> wrote:
>
> Hello,
>
> Has anyone managed to get a multipart/form-data submission working with
> the
> ajax theme?
> This is what I've got so far:
>
> <s:form namespace="/nodecorate" action="myaction"
> enctype="multipart/form-data" method="post">
>     <s:file value="image" name="image"></s:file>
>     <s:textfield value="title" name="item.title"/>...
>
>     <s:submit theme="ajax" targets="useritems" value="submit"></s:submit>
> </s:form>
>
> Which looks like it's almost working but the target div updates with
> '[object HTMLDocument]' and the action never gets invoked.
> If i remove the s:file element from the form then everything works as
> expected with the div updating with the result from the action.
>
> This looks to me like a problem with dojo as opposed to Struts2, I'm using
> version 2.0.6 by the way.
> Has anyone else encountered this or have any ideas?
>
> Any help appreciated.
> Thanks,
>
> Jack
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd