jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class ImageFileMaybeUploadWidget

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
                  extended byuk.co.weft.htform.ImageFileMaybeUploadWidget
All Implemented Interfaces:
java.lang.Cloneable, NodeGenerator, ResourceConsumer

public class ImageFileMaybeUploadWidget
extends FileMaybeUploadWidget

A file upload widget for a hypertext form, which assumes the file uploaded is an image which may reasonably be displayed. The widget will attempt to create a thumbnail of the file which has been uploaded; the name of the thumbnail will be the name of the file prepended by the prefix thumbPrefix, by default thumbnail_. If thumbnailing succeeds, it will leave in the context tokens composed of the name of the widget and the suffixes:

_image_height
Integer: the height of the uploaded image in pixels
_image_width
Integer: the width of the uploaded image in pixels
_thumb_height
Integer: the height of the generated thumbnail, in pixels
_thumb_width
Integer: the width of the generated thumbnail, in pixels

Version:
$Revision: 1.11.4.3 $ This revision: $Author: simon $
Author:
Simon Brooke

Field Summary
static java.lang.String DEFAULTTHUMBPREFIX
          what my thumbnail prefix should default to if not over-ridden
static java.lang.String IMAGEHEIGHTSUFFIX
          the suffix I will append to a name to create a token to store the image height on
static java.lang.String IMAGEWIDTHSUFFIX
          the suffix I will append to a name to create a token to store the image width on
static java.lang.String THUMBHEIGHTSUFFIX
          the suffix I will append to a name to create a token to store the thumbnail height on
protected  int thumbMaxHeight
          The maximum height for thumbnails
protected  int thumbMaxWidth
          The maximum width for thumbnails
protected  uk.co.weft.htform.ImageFileMaybeUploadWidget.ThumbnailPainter thumbPainter
          Something to create thumbnails
 java.lang.String thumbPrefix
          the prefix I will tag onto filename to create the name for the thumbnail
static java.lang.String THUMBWIDTHSUFFIX
          the suffix I will append to a name to create a token to store the thumbnail width on
 
Fields inherited from class uk.co.weft.htform.FileMaybeUploadWidget
previousValueMagicToken, VALUE_IS_FILE, VALUE_IS_PATH, VALUE_IS_URL, valueType
 
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
ImageFileMaybeUploadWidget()
          Creates a new ImageFileMaybeUploadWidget object.
ImageFileMaybeUploadWidget(java.lang.String name, java.lang.String prompt, java.lang.String help)
          name, prompt and helptext is best
ImageFileMaybeUploadWidget(java.lang.String name, java.lang.String prompt, java.lang.String help, java.lang.String thumbPrefix, int thumbWidth, int thumbHeight)
          Construct me with explicit values for my thumbnailing parameters
 
Method Summary
protected  void layoutValue(Context context)
          show the image which is the current value of this widget, if there is a value and it is accessible
protected  void preProcess(Context context)
          If a file was uploaded, maybe generate a thumbnail.
 
Methods inherited from class uk.co.weft.htform.FileMaybeUploadWidget
layout
 
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

IMAGEHEIGHTSUFFIX

public static final java.lang.String IMAGEHEIGHTSUFFIX
the suffix I will append to a name to create a token to store the image height on

See Also:
Constant Field Values

IMAGEWIDTHSUFFIX

public static final java.lang.String IMAGEWIDTHSUFFIX
the suffix I will append to a name to create a token to store the image width on

See Also:
Constant Field Values

THUMBHEIGHTSUFFIX

public static final java.lang.String THUMBHEIGHTSUFFIX
the suffix I will append to a name to create a token to store the thumbnail height on

See Also:
Constant Field Values

THUMBWIDTHSUFFIX

public static final java.lang.String THUMBWIDTHSUFFIX
the suffix I will append to a name to create a token to store the thumbnail width on

See Also:
Constant Field Values

DEFAULTTHUMBPREFIX

public static final java.lang.String DEFAULTTHUMBPREFIX
what my thumbnail prefix should default to if not over-ridden

See Also:
Constant Field Values

thumbPrefix

public java.lang.String thumbPrefix
the prefix I will tag onto filename to create the name for the thumbnail


thumbPainter

protected uk.co.weft.htform.ImageFileMaybeUploadWidget.ThumbnailPainter thumbPainter
Something to create thumbnails


thumbMaxHeight

protected int thumbMaxHeight
The maximum height for thumbnails


thumbMaxWidth

protected int thumbMaxWidth
The maximum width for thumbnails

Constructor Detail

ImageFileMaybeUploadWidget

public ImageFileMaybeUploadWidget()
Creates a new ImageFileMaybeUploadWidget object.


ImageFileMaybeUploadWidget

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


ImageFileMaybeUploadWidget

public ImageFileMaybeUploadWidget(java.lang.String name,
                                  java.lang.String prompt,
                                  java.lang.String help,
                                  java.lang.String thumbPrefix,
                                  int thumbWidth,
                                  int thumbHeight)
Construct me with explicit values for my thumbnailing parameters

Parameters:
name - name of this widget
prompt - prompt for this widget
help - helptext for this widget
thumbPrefix - prefix to be prepended to image file names to make the name of the associated thumbnail
thumbWidth - maximum width of thumbnails
thumbHeight - maximum height of thumbnails
Method Detail

layoutValue

protected void layoutValue(Context context)
                    throws DataFormatException,
                           javax.servlet.ServletException,
                           java.io.IOException
show the image which is the current value of this widget, if there is a value and it is accessible

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

preProcess

protected void preProcess(Context context)
                   throws DataStoreException,
                          javax.servlet.ServletException
If a file was uploaded, maybe generate a thumbnail.

Overrides:
preProcess in class FileMaybeUploadWidget
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