You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Dmitri Plotnikov <dp...@yahoo.com> on 2001/05/15 23:59:06 UTC

Defaults in html:form

I was implementing file uploading for my application
and for some time instead of the file contents I was
receiving the file name from the browser.  Turns out I
forgot to specify enctype="multipart/form-data" in my
html:form tag.  My fault.  

But it got me thinking...

Why wouldn't the enctype of a form default to
"multipart/form-data" if there was an enclosed
html:file tag?

So, I updated (my local versions) of both FileTag and
FormTag to address this issue. Struts' FormTag
generates the HTML <form> tag in doStartTag. Since I
needed to be able to override attributes of that tag
from within its body, I changed its superclass from
TagSupport to BodyTagSupport and moved all code
generation into doEndTag.

My FileTag implements this logic: it looks up the
FormTag (fortunately, it is immediately available as a
page context attribute), checks if that FormTag has a
non-null value for the enctype attribute and, if not,
sets it to "multipart/form-data".

The changes to the two classes I ended up making are
minor. I could post my versions of the two tags to the
group if you think it is a good idea. Is it?

- Dmitri Plotnikov
dmitri@plotnix.com



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/