Stripes

Partial form cause File Tag to fail

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: Release 1.5.1
  • Fix Version/s: Release 1.5.4
  • Component/s: None
  • Labels:
    None
  • Environment:
    Windows Vista, Tomcat, Jdk 1.6

Description

The Jsp:

<stripes:layout-render name="/layout/testLayout.jsp" title="User Home" action="/userHome.action">
<stripes:layout-component name="contents">
<stripes:form action="/userHome.action" partial="true">
<stripes:file name="fileBean" />
<stripes:submit name="upload" value="upload"/>
</stripes:form>
</stripes:layout-component>
</stripes:layout-render>

The Layout:

<stripes:layout-definition>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
</head>

<body>
<stripes:form action="${action}">
<div>${contents}</div>
</stripes:form>
</body>
</html>
</stripes:layout-definition>

---------------------
fileBean is always null in action bean.
It works if I take away the <stripes:form> tag in the layout, and remove partial="true" in the jsp.

Issue Links

Activity

Hide
Chut N Yee added a comment - 31/Mar/09 4:34 AM

I saw two "_sourcePage" hidden fields in the generated html. This could be the cause of the problem. I think this is also related to bug STS_672.

<form action="/CSIUser/userHome.action" method="post">
<div>
<form enctype="multipart/form-data" name="userHomeForm" action="/CSIUser/userHome.action" method="post">
<input name="fileBean" type="file" />
<input name="upload" value="upload" type="submit" />
<div style="display: none;">
<input type="hidden" name="_sourcePage" value="LA0Tyc3bYUwJDj1JmqNuE24xiSlmU_Id29300QhQp8Q=" />
<input type="hidden" name="__fp" value="0gZGESUOeXk=" /></div></form>

</div>
<div style="display: none;">
<input type="hidden" name="_sourcePage" value="gfUOHHnajR7kuDZDTvKJ0Lv0yBT2PidtxLAeU0DJM9A=" />
<input type="hidden" name="__fp" value="jXqEAZWUeUc=" />
</div>
</form>

Show
Chut N Yee added a comment - 31/Mar/09 4:34 AM I saw two "_sourcePage" hidden fields in the generated html. This could be the cause of the problem. I think this is also related to bug STS_672. <form action="/CSIUser/userHome.action" method="post"> <div> <form enctype="multipart/form-data" name="userHomeForm" action="/CSIUser/userHome.action" method="post"> <input name="fileBean" type="file" /> <input name="upload" value="upload" type="submit" /> <div style="display: none;"> <input type="hidden" name="_sourcePage" value="LA0Tyc3bYUwJDj1JmqNuE24xiSlmU_Id29300QhQp8Q=" /> <input type="hidden" name="__fp" value="0gZGESUOeXk=" /></div></form> </div> <div style="display: none;"> <input type="hidden" name="_sourcePage" value="gfUOHHnajR7kuDZDTvKJ0Lv0yBT2PidtxLAeU0DJM9A=" /> <input type="hidden" name="__fp" value="jXqEAZWUeUc=" /> </div> </form>
Hide
Chut N Yee added a comment - 31/Mar/09 7:51 PM

It works if I add the attribute enctype="multipart/form-data" explicitly in the form tag in the layout.

Is this a safe 'solution' to this bug?

Show
Chut N Yee added a comment - 31/Mar/09 7:51 PM It works if I add the attribute enctype="multipart/form-data" explicitly in the form tag in the layout. Is this a safe 'solution' to this bug?
Hide
Samuel Santos added a comment - 01/Apr/09 9:06 PM

HTML forms with file submission should always have the MIME media type defined as enctype="multipart/form-data".

See http://www.faqs.org/rfcs/rfc1867.html.

Show
Samuel Santos added a comment - 01/Apr/09 9:06 PM HTML forms with file submission should always have the MIME media type defined as enctype="multipart/form-data". See http://www.faqs.org/rfcs/rfc1867.html.
Hide
Ben Gunter added a comment - 16/Oct/09 1:11 PM

This is a symptom of a deeper problem with layouts and partial forms. It has to do with the way layouts are evaluated. The layout components are evaluated before the layout definition is evaluated. At the time the form tag within a component is evaluated, the form tag in the definition does not exist and therefore cannot be referenced by the any of the input tags in the component's partial form. In a normal form (i.e., one that is not split across a layout) the file input tag is responsible for setting its parent form's enctype attribute to allow for file uploads. This can't happen with a partial form defined within a layout component.

This is a complex problem that certainly will not be fixed for 1.5.2 and might have to wait until 1.6.

Show
Ben Gunter added a comment - 16/Oct/09 1:11 PM This is a symptom of a deeper problem with layouts and partial forms. It has to do with the way layouts are evaluated. The layout components are evaluated before the layout definition is evaluated. At the time the form tag within a component is evaluated, the form tag in the definition does not exist and therefore cannot be referenced by the any of the input tags in the component's partial form. In a normal form (i.e., one that is not split across a layout) the file input tag is responsible for setting its parent form's enctype attribute to allow for file uploads. This can't happen with a partial form defined within a layout component. This is a complex problem that certainly will not be fixed for 1.5.2 and might have to wait until 1.6.
Hide
Ben Gunter added a comment - 30/Sep/10 9:58 AM

This is fixed along with STS-391.

Show
Ben Gunter added a comment - 30/Sep/10 9:58 AM This is fixed along with STS-391.

People

Vote (0)
Watch (1)

Dates

  • Created:
    31/Mar/09 3:34 AM
    Updated:
    04/Jan/11 1:05 PM
    Resolved:
    30/Sep/10 9:58 AM