jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class CurrencyWidget

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.CurrencyWidget
All Implemented Interfaces:
java.lang.Cloneable, NodeGenerator, ResourceConsumer

public class CurrencyWidget
extends Widget

a widget to handle currency. Most world currencies are now 'decimal' with a larger denomination unit which is on hundred times the value of the smaller denomination unit: e.g. dollars and cents, pounds and pennies, etc. It makes sense to store these in the database as an integer number of the smaller denomination unit, which is what this widget does.

Version:
$Revision: 1.7.4.3 $ This revision: $Author: simon $
Author:
Simon Brooke (simon

Field Summary
protected  int iw_size
          my size
 
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
CurrencyWidget()
          If you use this constructor, you are strongly advised to use the init() method.
CurrencyWidget(java.lang.String myname)
          minimum initialisation is I must have a name
CurrencyWidget(java.lang.String myname, java.lang.String myprompt)
          name and prompt is better
CurrencyWidget(java.lang.String myname, java.lang.String myprompt, java.lang.String myhelp)
          name, prompt and helptext is better still.
 
Method Summary
 void layout(Context context, int tabIndex)
          layout just the widget, without prompt, help, or surrounding context.
protected  void layoutValue(Context context)
          Layout just my value on this output stream.
protected  void preProcess(Context context)
          Check that the value, if present, is parsable as a currency.
 java.lang.String scriptRequest(Context context)
          An integer widget does nothing clever without it's script
 
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, 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

iw_size

protected int iw_size
my size

Constructor Detail

CurrencyWidget

public CurrencyWidget()
If you use this constructor, you are strongly advised to use the init() method.

See Also:
Widget.init(Context)

CurrencyWidget

public CurrencyWidget(java.lang.String myname)
minimum initialisation is I must have a name


CurrencyWidget

public CurrencyWidget(java.lang.String myname,
                      java.lang.String myprompt)
name and prompt is better


CurrencyWidget

public CurrencyWidget(java.lang.String myname,
                      java.lang.String myprompt,
                      java.lang.String myhelp)
name, prompt and helptext is better still.

Method Detail

layout

public void layout(Context context,
                   int tabIndex)
            throws DataStoreException,
                   javax.servlet.ServletException,
                   java.io.IOException
layout just the widget, without prompt, help, or surrounding context. One argument, the context in which I am to be laid out

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

scriptRequest

public java.lang.String scriptRequest(Context context)
                               throws java.lang.Exception
An integer widget does nothing clever without it's script

Overrides:
scriptRequest in class Widget
Returns:
a comma separated list of JavaScript files which must be loaded to support this widget
Throws:
java.lang.Exception

layoutValue

protected void layoutValue(Context context)
                    throws DataFormatException,
                           javax.servlet.ServletException,
                           java.io.IOException
Layout just my value on this output stream. Pass the value through as a hidden input.

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
Check that the value, if present, is parsable as a currency.

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