org.mbari.siam.configt
Class HTMLControl

java.lang.Object
  extended by org.mbari.siam.configt.HTMLControl

public class HTMLControl
extends java.lang.Object

The HTMLControl class encapsulates the HTML forms element used to store and display the value of ConfigItems (configuration items). Methods are provided to get and set the item's value. Methods are also provided to configure the control's attributes and display parameters and and to retrieve an HTML snippet for the control.


Field Summary
protected  java.util.Vector _attributes
          Attributes
protected static org.apache.log4j.Logger _logger
          Log4J logger
protected  java.util.Hashtable _mappings
          Output Value Mappings
protected  java.lang.String _name
          Control name
protected  int _selectedIndex
          Index of selected value
protected  boolean _strictValues
          Strict values: do not allow values not defined in properties file
protected  int _type
          Control type
protected  java.util.Vector _values
          Allowed values (for SELECT, etc)
static int CHECKBOX
          Control type checkbox
static int RADIOBUTTON
          Control type radio button
static int SELECT
          Control type dropdown select box
static int TEXT
          Control type textbox
 
Constructor Summary
HTMLControl(java.lang.String name, int type, java.lang.String[] values, boolean strictValues)
          Constructor, just name and values
HTMLControl(java.lang.String name, int type, java.lang.String[] values, boolean strictValues, int selectedIndex)
          Constructor, the full monty
 
Method Summary
 void addAttribute(HTMLAttribute attribute)
           
 void addAttribute(java.lang.String name, java.lang.String value)
           
 void addAttributes(java.util.Vector attributes)
           
 void addOutputMapping(java.lang.String key, java.lang.String value)
           
 void addOutputMappings(java.util.Hashtable mappings)
           
 HTMLAttribute getAttribute(java.lang.String name)
           
 java.lang.String getAttributesHTML()
           
 java.lang.String getHTML()
          Get HTML for this control using current values
 java.lang.String getName()
          Get the control name
 java.lang.String getOutputMapping(java.lang.String name)
           
 int getSelectedIndex()
          Get index of currently selected value
 java.lang.String getSelectedValue()
          Get currently selected value
 java.lang.String getSelectedValue(boolean getMappedValue)
           
 int getType()
          Get control type ID
 java.util.Vector getValues()
          Get collection of known/allowed values
 int indexOf(java.lang.String value)
          Get index of specified value Returns -1 if the value is not found
 boolean isStrict()
           
 void removeAttribute(java.lang.String name)
           
 void removeOutputMapping(java.lang.String key)
           
 void setAttribute(java.lang.String name, java.lang.String value)
           
 void setName(java.lang.String name)
          Set the control name
 void setOutputMapping(java.lang.String key, java.lang.String value)
           
 void setSelectedIndex(int index)
          Set selected value
 void setSelectedValue(java.lang.String value)
          Set selected value; if specified value doesn't exist, add it to the list of values and use that.
 void setSelectedValue(java.lang.String value, java.lang.String dflt)
          Set selected value; if specified value doesn't exist, see if default value exists and set it to that.
 void setValues(java.lang.String[] values)
          Set collection of known/allowed values
 void setValues(java.util.Vector values)
          Set collection of known/allowed values
 java.lang.String show()
          Alternative to toString() with more information
 java.lang.String toString()
          Override toString method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_logger

protected static org.apache.log4j.Logger _logger
Log4J logger


TEXT

public static final int TEXT
Control type textbox

See Also:
Constant Field Values

CHECKBOX

public static final int CHECKBOX
Control type checkbox

See Also:
Constant Field Values

RADIOBUTTON

public static final int RADIOBUTTON
Control type radio button

See Also:
Constant Field Values

SELECT

public static final int SELECT
Control type dropdown select box

See Also:
Constant Field Values

_name

protected java.lang.String _name
Control name


_type

protected int _type
Control type


_values

protected java.util.Vector _values
Allowed values (for SELECT, etc)


_attributes

protected java.util.Vector _attributes
Attributes


_mappings

protected java.util.Hashtable _mappings
Output Value Mappings


_selectedIndex

protected int _selectedIndex
Index of selected value


_strictValues

protected boolean _strictValues
Strict values: do not allow values not defined in properties file

Constructor Detail

HTMLControl

public HTMLControl(java.lang.String name,
                   int type,
                   java.lang.String[] values,
                   boolean strictValues)
Constructor, just name and values


HTMLControl

public HTMLControl(java.lang.String name,
                   int type,
                   java.lang.String[] values,
                   boolean strictValues,
                   int selectedIndex)
Constructor, the full monty

Method Detail

setName

public void setName(java.lang.String name)
Set the control name


getName

public java.lang.String getName()
Get the control name


getSelectedIndex

public int getSelectedIndex()
Get index of currently selected value


indexOf

public int indexOf(java.lang.String value)
Get index of specified value Returns -1 if the value is not found


getValues

public java.util.Vector getValues()
Get collection of known/allowed values


setValues

public void setValues(java.lang.String[] values)
Set collection of known/allowed values


setValues

public void setValues(java.util.Vector values)
Set collection of known/allowed values


getType

public int getType()
Get control type ID


removeAttribute

public void removeAttribute(java.lang.String name)

addAttribute

public void addAttribute(HTMLAttribute attribute)

addAttributes

public void addAttributes(java.util.Vector attributes)

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)

getAttribute

public HTMLAttribute getAttribute(java.lang.String name)

getAttributesHTML

public java.lang.String getAttributesHTML()

getHTML

public java.lang.String getHTML()
Get HTML for this control using current values


getSelectedValue

public java.lang.String getSelectedValue()
Get currently selected value


getSelectedValue

public java.lang.String getSelectedValue(boolean getMappedValue)

setSelectedIndex

public void setSelectedIndex(int index)
                      throws java.lang.Exception
Set selected value

Throws:
java.lang.Exception

setSelectedValue

public void setSelectedValue(java.lang.String value,
                             java.lang.String dflt)
                      throws java.lang.Exception
Set selected value; if specified value doesn't exist, see if default value exists and set it to that. If the default doesn't exist, add it to the list of values and use that.

Throws:
java.lang.Exception

setSelectedValue

public void setSelectedValue(java.lang.String value)
                      throws java.lang.Exception
Set selected value; if specified value doesn't exist, add it to the list of values and use that.

Throws:
java.lang.Exception

isStrict

public boolean isStrict()

removeOutputMapping

public void removeOutputMapping(java.lang.String key)

addOutputMapping

public void addOutputMapping(java.lang.String key,
                             java.lang.String value)

addOutputMappings

public void addOutputMappings(java.util.Hashtable mappings)

setOutputMapping

public void setOutputMapping(java.lang.String key,
                             java.lang.String value)

getOutputMapping

public java.lang.String getOutputMapping(java.lang.String name)

toString

public java.lang.String toString()
Override toString method

Overrides:
toString in class java.lang.Object

show

public java.lang.String show()
Alternative to toString() with more information



Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.