You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jon Wilmoth <jo...@yahoo.com> on 2009/02/17 23:44:05 UTC

Why does s:file break an ajax form?

I'm curious to know why the s:file tag breaks an 2.1.6 ajax form resulting in a javascript error "'message' is null or not an object" in IE6 (target div isn't updated).  The form, which contains some input tags and a s:file tag, works when the standard s:submit tag is used, but doesn't work with the sx:submit tag.  Removing the s:file tag from the form when using the sx:submit tag works.  Below is a summary of what works and doesn't work using the "Remote form replacing another div" sample from the showcase:
 
Works (ajax w/out file input):
<div id='two' style="border: 1px solid yellow;"><b>initial content</b></div>
<s:form id='theForm2' cssStyle="border: 1px solid green;" action='AjaxRemoteForm' method='post'>
    <input type='text' name='data' value='Struts User'> 
    <sx:submit value="GO2" targets="two"/>
</s:form>

Works (no ajax w/file input):
<s:form id='theForm2' cssStyle="border: 1px solid green;" action='AjaxRemoteForm' method='post' enctype="multipart/form-data">
    <input type='text' name='data' value='Struts User'>
    <s:file name="file"/>
    <s:submit value="GO2"/>
</s:form>

Doesn't Work (ajax w/file input):
<s:form id='theForm2' cssStyle="border: 1px solid green;" action='AjaxRemoteForm' method='post' enctype="multipart/form-data">
    <input type='text' name='data' value='Struts User'>
    <s:file name="file"/>
    <sx:submit value="GO2" targets="two"/>
</s:form>

Is there a Struts solution (w/out using 3rd party plugins) for an ajax based form submission with files?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Why does s:file break an ajax form?

Posted by Richard Sayre <ri...@gmail.com>.
I have encountered the same problem.  While I have not fixed it with
Ajax yet, the reason it does not work is because you can not submit a
file through Ajax.  You need to use an iFrame to submit file uploads.

On Tue, Feb 17, 2009 at 7:14 PM, Jon Wilmoth <jo...@yahoo.com> wrote:
> I'm curious to know why the s:file tag breaks an 2.1.6 ajax form resulting in a javascript error "'message' is null or not an object" in IE6 (target div isn't updated).  The form, which contains some input tags and a s:file tag, works when the standard s:submit tag is used, but doesn't work with the sx:submit tag.  Removing the s:file tag from the form when using the sx:submit tag works.  Below is a summary of what works and doesn't work using the "Remote form replacing another div" sample from the showcase:
>
> Works (ajax w/out file input):
> <div id='two' style="border: 1px solid yellow;"><b>initial content</b></div>
> <s:form id='theForm2' cssStyle="border: 1px solid green;" action='AjaxRemoteForm' method='post'>
>     <input type='text' name='data' value='Struts User'>
>     <sx:submit value="GO2" targets="two"/>
> </s:form>
>
> Works (no ajax w/file input):
> <s:form id='theForm2' cssStyle="border: 1px solid green;" action='AjaxRemoteForm' method='post' enctype="multipart/form-data">
>     <input type='text' name='data' value='Struts User'>
>     <s:file name="file"/>
>     <s:submit value="GO2"/>
> </s:form>
>
> Doesn't Work (ajax w/file input):
> <s:form id='theForm2' cssStyle="border: 1px solid green;" action='AjaxRemoteForm' method='post' enctype="multipart/form-data">
>     <input type='text' name='data' value='Struts User'>
>     <s:file name="file"/>
>     <sx:submit value="GO2" targets="two"/>
> </s:form>
>
> Is there a Struts solution (w/out using 3rd party plugins) for an ajax based form submission with files?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org