net.sourceforge.stripes.tag
Class InputFileTag

java.lang.Object
  extended by net.sourceforge.stripes.tag.StripesTagSupport
      extended by net.sourceforge.stripes.tag.HtmlTagSupport
          extended by net.sourceforge.stripes.tag.InputTagSupport
              extended by net.sourceforge.stripes.tag.InputFileTag
All Implemented Interfaces:
DynamicAttributes, JspTag, Tag, TryCatchFinally

public class InputFileTag
extends InputTagSupport
implements Tag

Tag that generates HTML form fields of type <input type="file" ... />. The only functionality provided above and beyond a straight HTML input tag is that the tag will find its enclosing form tag and ensure that the for is set to POST instead of GET, and that the encoding type of the form is properly set to multipart/form-data as both these settings are necessary to correctly perform file uploads.

Does not perform repopulation because default values for <input type="file/> are not allowed by the HTML specification. One can only imagine this is because a malicious page author could steal a user's files by defaulting the value and using JavaScript to auto-submit forms! As a result the tag does not accept a body because it would have no use for any generated content.

Author:
Tim Fennell

Field Summary
 
Fields inherited from class net.sourceforge.stripes.tag.InputTagSupport
errorRenderer, fieldErrors
 
Fields inherited from class net.sourceforge.stripes.tag.StripesTagSupport
pageContext, parentTag
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
InputFileTag()
          Basic constructor that sets the input tag's type attribute to "file".
 
Method Summary
 int doEndInputTag()
          Writes out a singleton tag representing the values stored on this tag instance.
 int doStartInputTag()
          Locates the parent tag and modifies it's method and enctype to be suitable for file upload.
 String getAccept()
          Returns the value, if any, set with setAccept().
 void setAccept(String accept)
          Sets the content types accepted for files being uploaded.
 
Methods inherited from class net.sourceforge.stripes.tag.InputTagSupport
doCatch, doEndTag, doFinally, doStartTag, format, format, getActionBean, getDisabled, getFieldErrors, getFormatPattern, getFormatType, getLocalizedFieldName, getLocalizedFieldName, getName, getOverrideValueOrValues, getParentFormTag, getReadonly, getSingleOverrideValue, getSize, getValidationMetadata, getValueOnPage, hasErrors, isItemSelected, loadErrors, makeFocused, registerWithParentForm, setDisabled, setFocus, setFormatPattern, setFormatType, setName, setReadonly, setSize
 
Methods inherited from class net.sourceforge.stripes.tag.HtmlTagSupport
evaluateExpression, get, getAccesskey, getAttributes, getBodyContent, getBodyContentAsString, getCssClass, getDir, getId, getLang, getOnblur, getOnchange, getOnclick, getOndblclick, getOnfocus, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnselect, getStyle, getTabindex, getTitle, release, set, setAccesskey, setBodyContent, setClass, setCssClass, setDir, setDynamicAttribute, setId, setLang, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setStyle, setTabindex, setTitle, toString, writeAttributes, writeCloseTag, writeOpenTag, writeSingletonTag
 
Methods inherited from class net.sourceforge.stripes.tag.StripesTagSupport
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
 

Constructor Detail

InputFileTag

public InputFileTag()
Basic constructor that sets the input tag's type attribute to "file".

Method Detail

setAccept

public void setAccept(String accept)
Sets the content types accepted for files being uploaded.


getAccept

public String getAccept()
Returns the value, if any, set with setAccept().


doStartInputTag

public int doStartInputTag()
                    throws JspException
Locates the parent tag and modifies it's method and enctype to be suitable for file upload.

Specified by:
doStartInputTag in class InputTagSupport
Returns:
SKIP_BODY because the tag does not allow a body
Throws:
JspException - if the enclosing form tag cannot be located

doEndInputTag

public int doEndInputTag()
                  throws JspException
Writes out a singleton tag representing the values stored on this tag instance.

Specified by:
doEndInputTag in class InputTagSupport
Returns:
EVAL_PAGE is always returned
Throws:
JspException - if a problem is encountered writing to the JSP page's output


? Copyright 2005-2006, Stripes Development Team.