struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <davelnew...@gmail.com>
Subject Re: Struts nested <s:form> and <s:file> tags
Date Wed, 27 Oct 2010 22:47:40 GMT
It's not legal to nest form tags; that's bogus HTML.

I don't understand what you mean by "the rest of the page doesn't
work"; a file tag is part of a form. You don't submit just part of a
form, you submit all of it. If you're trying to do something like an
Ajax upload, you'd need to do it differently. If you're not, the
entire form needs to reflect it'll be uploading a file.

Dave

On Wed, Oct 27, 2010 at 6:42 PM, Dave Westerman <dlwester@us.ibm.com> wrote:
> I am trying to use the <s:file> tag to allow uploading a file to the
> server. However, this tag has to be within a larger overall form.
>
> <s:form>
> ...
>    <s:file name="uploadCustomImageFile" />
>    <s:submit type="button"
> action="%{siteId}/appearance/uploadCustomImage" name="Upload File"/>
> ...
>    <s:submit name=”Save” />
> </s:form>
>
>
> However, whenever I use the above code, I get the following error when I
> click on the 'Upload File' button:
>
> Invalid field value for field "uploadCustomImageFile"
>
>
> If I wrap the <s:file> in its own <s:form>, nested within the main form,
I
> get the same error message:
>
> <s:form>
> ...
>    <s:form action="%{siteId}/appearance/uploadCustomImage"
>        method="post" enctype="multipart/form-data">
>        <s:file name="uploadCustomImageFile" />
>        <s:submit type="button" name="Upload File" />
>    </s:form>
> ...
>    <s:submit name=”Save” />
> </s:form>
>
>
> However, if I remove the main “outer” form from my JSP, then the above
> <s:file> in its own <s:form> works.
>
>    <s:form action="%{siteId}/appearance/uploadCustomImage"
>        method="post" enctype="multipart/form-data">
>        <s:file name="uploadCustomImageFile" />
>        <s:submit type="button" name="Upload File" />
>    </s:form>
>
>
> However, the rest of the page doesn't work, of course.
>
> Is it legal to nest <s:form> tags within each other? Or is there something
> going wrong with the <s:file> tag?
>
>

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


Mime
View raw message