jacquard 1.12.0 by The Web Engineering Factory and Toolworks

uk.co.weft.htform
Class MenuOption

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

public class MenuOption
extends NodeGeneratorImpl
implements java.lang.Cloneable

An option in a MenuWidget. Note that MenuOption has a back-pointer to its menu, and consequently it is not legal to add an option to a menu it doesn't belong to.

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

Field Summary
protected  boolean debug
          whether or not I'm in debug mode; if I am I may print debugging messages to System.err
protected  int width
          The maximum number of characters I will show.
 
Fields inherited from class uk.co.weft.domutil.NodeGeneratorImpl
name, 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
MenuOption(java.lang.String mylabel, MenuWidget menu)
          minimum initialisation: I should have a label.
MenuOption(java.lang.String mylabel, java.lang.String myvalue, MenuWidget menu)
          label and value is better.
 
Method Summary
 java.lang.Object clone()
          A menu option may be cloned
 Node generate(Document doc, Context context)
          Generate a node representing the XHTML 1.0 representation of this option.
 java.lang.String getLabel()
           
 java.lang.String getName()
          not really useful in this instance but required by the NodeGenerator interface
 java.lang.String getValue()
           
 int getWidth(Context context)
          get my visible width in characters in this context.
 void init(Context config)
          Initialise me with this configuration.
protected  void layout(Context context, java.lang.Object current)
          lay me out on this output stream; select me if my value is current.
protected  void layout(Context context, java.lang.Object current, java.lang.String selected)
          lay me out on this output stream, using this value for the selected flag
 void setDebug(boolean debug)
          whether or not to set debugging mode.
 
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

debug

protected boolean debug
whether or not I'm in debug mode; if I am I may print debugging messages to System.err


width

protected int width
The maximum number of characters I will show. 0 means unlimited

Constructor Detail

MenuOption

public MenuOption(java.lang.String mylabel,
                  MenuWidget menu)
minimum initialisation: I should have a label. Trim it to remove redundent spaces.


MenuOption

public MenuOption(java.lang.String mylabel,
                  java.lang.String myvalue,
                  MenuWidget menu)
label and value is better.

Method Detail

getLabel

public java.lang.String getLabel()
Returns:
Returns the label.

getValue

public java.lang.String getValue()
Returns:
Returns the value.

setDebug

public void setDebug(boolean debug)
whether or not to set debugging mode. If true, the generator _may_ write debugging messages to System.err

Specified by:
setDebug in interface NodeGenerator
Overrides:
setDebug in class NodeGeneratorImpl
Parameters:
debug - whether or not to set debugging mode
Since:
Jacquard 1.10

getName

public java.lang.String getName()
not really useful in this instance but required by the NodeGenerator interface

Specified by:
getName in interface NodeGenerator
Overrides:
getName in class NodeGeneratorImpl
Returns:
my name

getWidth

public int getWidth(Context context)
get my visible width in characters in this context.


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
A menu option may be cloned

Throws:
java.lang.CloneNotSupportedException

generate

public Node generate(Document doc,
                     Context context)
Generate a node representing the XHTML 1.0 representation of this option. Essentially this method is the Jacquard 2 replacement for MenuOption.layout(), q.v.

Specified by:
generate in interface NodeGenerator
Specified by:
generate in class NodeGeneratorImpl
Parameters:
doc - the document of which the new node will form part
context - the context in which the operation is to be performed
Returns:
the element created.
See Also:
layout(uk.co.weft.dbutil.Context, java.lang.Object)

init

public void init(Context config)
          throws InitialisationException
Initialise me with this configuration. Default does nothing. Specialise if needed.

Specified by:
init in interface NodeGenerator
Specified by:
init in class NodeGeneratorImpl
Parameters:
config - a context containing configuration information.
Throws:
InitialisationException
Since:
Jacquard 1.8.0

layout

protected void layout(Context context,
                      java.lang.Object current)
               throws java.io.IOException
lay me out on this output stream; select me if my value is current.

Throws:
java.io.IOException

layout

protected void layout(Context context,
                      java.lang.Object current,
                      java.lang.String selected)
               throws java.io.IOException
lay me out on this output stream, using this value for the selected flag

Throws:
java.io.IOException

jacquard 1.12.0 by The Web Engineering Factory and Toolworks