jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class ActionWidget

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.ActionWidget
All Implemented Interfaces:
java.lang.Cloneable, NodeGenerator, ResourceConsumer
Direct Known Subclasses:
BasicConfigurator.ConfigureWidget, FirstTime.InitialisationWidget

public class ActionWidget
extends Widget
implements NodeGenerator

An action widget for a hypertext form. Essentially a wrapper around a submit button, but... The theory of it is that the action widget carries it's own action. In practice, of course, because the HTML submit input specification makes the value of the submit input the same as the text on the submit input, there is no actual way of differentiating (at the receiving end) between two submit inputs with the same text.

So, You may have as many ActionWidgets as you like in a Form. If two (or more) do exactly the same thing there's no real harm in their having the same label. But: the despatcher method in the form will pass control to the execute() method of the first ActionWidget which claims it, and the default claim method matches the value against the value of the ActionWidget the user clicked. OK? Got that? You have been warned.

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

Field Summary
static java.lang.String commandToken
           
 
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
ActionWidget()
          set up my input type
ActionWidget(java.lang.String myname)
          I would like a name
ActionWidget(java.lang.String name, java.lang.String prompt)
          name and prompt is better
ActionWidget(java.lang.String name, java.lang.String prompt, java.lang.String help)
          name, prompt and helptext is better still.
 
Method Summary
protected  void execute(Context c)
          the default execute method does nothing whatever.
 Node generateInnerHTML(Document doc, Context context)
          Generate a node representing the XHTML 1.0 representation of this widget.
protected  void layout(Context context, java.lang.String inputType, int tabIndex)
          layout *just* the widget, without prompt, help, or surrounding context.
protected  boolean maybeExecute(Context context, Context whinges)
          decide whether to claim the right to execute my action in this context; if claiming the right execute the action and return true; otherwise just return false.
protected  boolean validateOK(Context context, Context whinges)
          Determine whether it is safe to execute in this context.
 
Methods inherited from class uk.co.weft.htform.Widget
clone, generate, generateAttributes, generateAttributes, generateHTML, generateHTMLPrompt, generateValue, generateXML, getContextAttribute, getCssClass, getHeight, getHelp, getName, getPrompt, getTabPlaces, getType, getWidth, init, layout, layout, layout, layoutAttribute, layoutAttributes, layoutValue, makeReady, maybeLayout, maybeLayout, onloadRequest, onloadRequest, postProcess, preProcess, 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
 
Methods inherited from interface uk.co.weft.domutil.NodeGenerator
generate, getName, getNamespaceURI, init, setDebug
 

Field Detail

commandToken

public static final java.lang.String commandToken
See Also:
Constant Field Values
Constructor Detail

ActionWidget

public ActionWidget()
set up my input type


ActionWidget

public ActionWidget(java.lang.String myname)
I would like a name


ActionWidget

public ActionWidget(java.lang.String name,
                    java.lang.String prompt)
name and prompt is better


ActionWidget

public ActionWidget(java.lang.String name,
                    java.lang.String prompt,
                    java.lang.String help)
name, prompt and helptext is better still.

Method Detail

layout

protected void layout(Context context,
                      java.lang.String inputType,
                      int tabIndex)
               throws DataFormatException,
                      javax.servlet.ServletException,
                      java.io.IOException
layout *just* the widget, without prompt, help, or surrounding context. Note that the input name of an action widget is always 'action', and what was given to us as it's name appears as it's value.

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

maybeExecute

protected boolean maybeExecute(Context context,
                               Context whinges)
                        throws java.lang.Exception
decide whether to claim the right to execute my action in this context; if claiming the right execute the action and return true; otherwise just return false.

Parameters:
context - the context containing all the values entered by the user
whinges - a context containing exceptions thrown while pre-processing widgets
Throws:
java.lang.Exception

validateOK

protected boolean validateOK(Context context,
                             Context whinges)
Determine whether it is safe to execute in this context. A method of its own to allow for specialisation. Default behaviour: always return true (i.e. ignore whinges).

Parameters:
context - the context containing all the values entered by the user
whinges - a context containing exceptions thrown while pre-processing widgets
Returns:
true if safe to execute, else false.

execute

protected void execute(Context c)
                throws java.lang.Exception
the default execute method does nothing whatever. You *must* specialise this in order to do anything useful.

Parameters:
c - the context of this request
Throws:
doesn't - actually throw any exception but things which specialise it may want to.
java.lang.Exception

generateInnerHTML

public Node generateInnerHTML(Document doc,
                              Context context)
                       throws GenerationException
Generate a node representing the XHTML 1.0 representation of this widget.

Overrides:
generateInnerHTML in class Widget
Parameters:
doc - the document within which I am to be created
context - the context in which I am to be created.
Returns:
an element representing either the INPUT element itself or a SPAN element containing the INPUT element and any other functionally supporting stuff (SCRIPTs, other INPUTs, APPLETs etc
Throws:
GenerationException
See Also:
Widget.layout(Context), Widget.generateHTML(Document, Context)

jacquard 1.12.0 by The Web Engineering Factory and Toolworks