jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class FileMaybeUploadWidget

java.lang.Object
  extended byuk.co.weft.htform.ResourceConsumerImpl
      extended byuk.co.weft.domutil.NodeGeneratorImpl
          extended byuk.co.weft.htform.Widget
              extended byuk.co.weft.htform.FileMaybeUploadWidget
All Implemented Interfaces:
java.lang.Cloneable, NodeGenerator, ResourceConsumer
Direct Known Subclasses:
ImageFileMaybeUploadWidget

public class FileMaybeUploadWidget
extends Widget

A file upload widget for a hypertext form. In order to set the type of file which is expected, use setAttribute( "accept", "<mime types list>"), for example setAttribute( "accept", "image/gif, image/jpeg, image/png")

Note that this class requires that the upload_dir_path and upload_dir_url parameters of the Servlet in which it occurs are set up correctly, and that the directory is writable.

Version:
$Revision: 1.11.4.4 $ This revision: $Author: simon $
Author:
Simon Brooke
See Also:
MaybeUploadServlet

Field Summary
static java.lang.String previousValueMagicToken
          magic token to identify the previous value in an UploadWidget
static int VALUE_IS_FILE
          set valueType to this if you want the value in the context to be a java.io.File object ( this is the default)
static int VALUE_IS_PATH
          set valueType to this if you want the value in the context to be a String representation of the canonical form of the path to the file
static int VALUE_IS_URL
          set valueType to this if you want the value in the context to be a java.net.URL object (you must provide a valid upload_dir_url configuration parameter to the Servlet this widget is in for this to work)
 int valueType
          what sort of value should I put in the context?
 
Fields inherited from class uk.co.weft.htform.Widget
ACTIONCSSCLASS, akprompt, attrs, CONTEXTATTRIBUTESSUFFIX, cssClass, DANGEROUSCSSCLASS, debug, DEFAULTTOKEN, dflt, form, generateAs, GENERATEASHTML, GENERATEASXFORM, GENERATEASXML, help, HELPTOKEN, immutable, ISIMMUTABLETOKEN, ISMANDATORYTOKEN, mandatory, MANDATORYCSSCLASS, maxVisibleSize, name, NAMETOKEN, OPTIONALCSSCLASS, PREVIOUSVALUESUFFIX, prompt, PROMPTTOKEN, size, SIZETOKEN, type, TYPETOKEN
 
Fields inherited from class uk.co.weft.domutil.NodeGeneratorImpl
namespaceURI
 
Fields inherited from class uk.co.weft.htform.ResourceConsumerImpl
resourceBundleName
 
Fields inherited from interface uk.co.weft.domutil.NodeGenerator
NAMESPACEURIMAGICTOKEN
 
Fields inherited from interface uk.co.weft.htform.ResourceConsumer
RESOURCEBUNDLEMAGICTOKEN
 
Constructor Summary
FileMaybeUploadWidget()
          Creates a new FileMaybeUploadWidget object.
FileMaybeUploadWidget(java.lang.String name, java.lang.String prompt, java.lang.String help)
          name, prompt and helptext is best
 
Method Summary
 void layout(Context context, int tabIndex)
          It isn't easy to represent the current value of a file widget
protected  void layoutValue(Context context)
          layout the value currently associated with my name.
protected  void preProcess(Context context)
          If a file was uploaded, compute and set my value in the Context as indicated by my valueType
 
Methods inherited from class uk.co.weft.htform.Widget
clone, generate, generateAttributes, generateAttributes, generateHTML, generateHTMLPrompt, generateInnerHTML, generateValue, generateXML, getContextAttribute, getCssClass, getHeight, getHelp, getName, getPrompt, getTabPlaces, getType, getWidth, init, layout, layout, layout, layoutAttribute, layoutAttributes, makeReady, maybeLayout, maybeLayout, onloadRequest, onloadRequest, postProcess, scriptRequest, scriptRequest, setAttribute, setContextAttribute, setCssClass, setDebug, setDefault, setHelp, setImmutable, setMandatory, setMandatory, setName, setPrompt, setSize, setType
 
Methods inherited from class uk.co.weft.domutil.NodeGeneratorImpl
getNamespaceURI, setNamespaceURI
 
Methods inherited from class uk.co.weft.htform.ResourceConsumerImpl
getContextOrResource, getResource, getResourceOrContext, getResourceString, grs, grs
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE_IS_FILE

public static final int VALUE_IS_FILE
set valueType to this if you want the value in the context to be a java.io.File object ( this is the default)

See Also:
Constant Field Values

VALUE_IS_URL

public static final int VALUE_IS_URL
set valueType to this if you want the value in the context to be a java.net.URL object (you must provide a valid upload_dir_url configuration parameter to the Servlet this widget is in for this to work)

See Also:
Constant Field Values

VALUE_IS_PATH

public static final int VALUE_IS_PATH
set valueType to this if you want the value in the context to be a String representation of the canonical form of the path to the file

See Also:
Constant Field Values

previousValueMagicToken

public static final java.lang.String previousValueMagicToken
magic token to identify the previous value in an UploadWidget

See Also:
Constant Field Values

valueType

public int valueType
what sort of value should I put in the context?

Constructor Detail

FileMaybeUploadWidget

public FileMaybeUploadWidget()
Creates a new FileMaybeUploadWidget object.


FileMaybeUploadWidget

public FileMaybeUploadWidget(java.lang.String name,
                             java.lang.String prompt,
                             java.lang.String help)
name, prompt and helptext is best

Method Detail

layout

public void layout(Context context,
                   int tabIndex)
            throws DataStoreException,
                   javax.servlet.ServletException,
                   java.io.IOException
It isn't easy to represent the current value of a file widget

Overrides:
layout in class Widget
Parameters:
context - the service context
tabIndex - the tabindex to use, ot the tab index of my first sub-widget if I have more than one
Throws:
DataStoreException - I don't, but things which specialise me may
javax.servlet.ServletException - I don't, but things which specialise me may
java.io.IOException - if can't write to the output stream

layoutValue

protected void layoutValue(Context context)
                    throws DataFormatException,
                           javax.servlet.ServletException,
                           java.io.IOException
layout the value currently associated with my name. Do not include a hiddenWidget, because with file widgets what's associated with the name is not necessarily what we want to send

Overrides:
layoutValue in class Widget
Parameters:
context - the service context
Throws:
DataStoreException - I don't, but things which specialise me may
javax.servlet.ServletException - I don't, but things which specialise me may
java.io.IOException - if can't write to the output stream
DataFormatException

preProcess

protected void preProcess(Context context)
                   throws DataStoreException,
                          javax.servlet.ServletException
If a file was uploaded, compute and set my value in the Context as indicated by my valueType

Overrides:
preProcess in class Widget
Parameters:
context - the Context of the service in which I'm called
Throws:
DataFormatException - if data fails validation test
javax.servlet.ServletException - if the thing itself breaks
DataStoreException

jacquard 1.12.0 by The Web Engineering Factory and Toolworks