Expresso 5-6

com.jcorporate.expresso.core.controller
Class Input

java.lang.Object
  extended bycom.jcorporate.expresso.core.controller.ControllerElement
      extended bycom.jcorporate.expresso.core.controller.Input
All Implemented Interfaces:
Cacheable, Cloneable, Serializable

public class Input
extends ControllerElement
implements Cloneable, Cacheable

An Input object is one of the three types of objects generated by a Controller when it transitions from one state to another. The other two are Actions and Outputs.
An Input is a request for information from the user. It may or may not have a default value, a list of valid values, and other attributes - any or all of which can be used by the user interface, which can be a JSP, Servlet, application, or even an applet.

Recognized Types:

The following types are recognized by the expresso framework and automatically rendered: You may add your own types or ignore them if you are doing your own page rendering.

checkbox: Renders as a checkbox. If multivalued=true then will render the options as a list of checkboxes.

radio: If multivalued, will render all options as a list of radio buttons

checkbox-vertical: Only relevent for multivalues, renders the checkbox style as vertical

See Also:
Serialized Form

Field Summary
static String ATTRIBUTE_CHECKBOX
          The Input is intended to be rendered as a check box
static String ATTRIBUTE_CHECKBOX_VERTICAL
          The Input is intended to be rendered as a vertically aligned checkbox
static String ATTRIBUTE_CSS_STYLE
          Defines the CSS style to use when rendering the input.
static String ATTRIBUTE_DROPDOWN
          The Input is intended to be rendered as a drop down box
static String ATTRIBUTE_FILE
          The Input is indended to be a file upload box.
static String ATTRIBUTE_HIDDEN
          The Input is intended to be rendered as a Hidden Field
static String ATTRIBUTE_LISTBOX
          The Input is intended to be rendered as a List Box
static String ATTRIBUTE_MULTIVALUED
          Means that the Input will be some sort of multi-valued field and has valid values associated with it.
static String ATTRIBUTE_ORIGINAL_VALUE
          Attribute that contains the original value of this input.
static String ATTRIBUTE_PASSWORD
          Attribute for password boxes.
static String ATTRIBUTE_RADIO
          The Input is intended to be rendered as a Radio Button
static String ATTRIBUTE_RADIO_VERTICAL
          The Input is intended to be rendered as a Vertically Aligned Radio Button
static String ATTRIBUTE_READONLY
          The Input is intended to be read only.
static String ATTRIBUTE_TEXTAREA
          The Input is intended to be rendered as a Text Area
static String ATTRIBUTE_TEXTLINE
          text input, single line (as opposed to text area)
static String ATTRIBUTE_TYPE
          Attribute defines the HTML Type that will be used with the Input
static String SELECTED
          constant for JSTL attribute for 'selectness' of a given input
 
Constructor Summary
Input()
          Default constructor
Input(String newName)
          Convenience constructor - to make a new Input object with a specific name
Input(String newName, String newLabel)
          Constructor that sets the name and the label of the input
 
Method Summary
 void addDefaultValue(String newValue)
          supply another default value for this Input object; appropriate for multiple selection items
 void addValidValue(String value, String descrip)
          Add a valid value to the Input's dropdown
 Object clone()
          Clones the input as per standard java.lang.Object specifications
static ControllerElement fromXML(org.w3c.dom.Node n)
          Return a controller element based upon the xml fragment [Factory Method]
 String getContent()
          (Convenience for JSTL access, to be parallel with Output) Return a single default value supplied by the Controller for this Input object; returns the 0th item in list (we expect this function to be used only for single selection items)
 String getDefaultValue()
          Return a single default value supplied by the Controller for this Input object; returns the 0th item in list (we expect this function to be used only for single selection items)
 ArrayList getDefaultValueList()
          Return a list of default values supplied by the Controller for this Input object; appropriate for multiple selection items
 String getKey()
          Retrieve the key for the input.
 String getLookup()
          Returns the class name of a database object that can be used to look up valid values for this Input item, if there is one.
 int getMaxLength()
          Return the maximum recommended length of the value for this Input object.
 String getMultiple()
          Retrieve the multi select status.
 String getSelectedDisplay()
          get the display string associated with the currently-selected (default).
 Vector getValidValues()
          Return the list of Valid Values that are allowed for this Input item.
 void setDefaultValue(ControllerResponse response)
          Convenience method to quickly set the default value from the form cache.
 void setDefaultValue(List list)
          supply a list of default values for this Input object; appropriate for multiple selection items
 void setDefaultValue(String newValue)
          supply a default value for this Input object; appropriate for single selection items; sets the 0th item in underlying list
 void setKey(String newKey)
          The Key of the Input
 void setLookup(String s)
          Set the name of the "lookup object" - the database object that the client can use to look up valid values for this Input item.
 void setMaxLength(int newMaxLength)
          Set the maximum recommended length of the Input object
 void setMultiple(String newMultiple)
          Set the the Input object allow multiple selections
 void setName(String newName)
          Sets the inputs name.
 void setType(String newType)
          Sets the input type
 void setValidValues(Vector v)
          Method for the Controller to specify the valid values for this Input item
 FastStringBuffer toXML(FastStringBuffer stream)
          Concert the object to an xml fragment.
 
Methods inherited from class com.jcorporate.expresso.core.controller.ControllerElement
addNested, allNested, fromXML, getAttribute, getAttributes, getAttributesOrNull, getContent, getContents, getControllerResponse, getDescription, getDisplayLength, getLabel, getLines, getName, getNested, getNested, getNestedCount, getNestedIterator, getNestedMap, getNestedOrNull, getParent, getTitle, getType, remove, removeNested, setAttribute, setControllerResponse, setDescription, setDisplayLength, setLabel, setLines, setParent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECTED

public static final String SELECTED
constant for JSTL attribute for 'selectness' of a given input

See Also:
Constant Field Values

ATTRIBUTE_LISTBOX

public static final String ATTRIBUTE_LISTBOX
The Input is intended to be rendered as a List Box

See Also:
Constant Field Values

ATTRIBUTE_DROPDOWN

public static final String ATTRIBUTE_DROPDOWN
The Input is intended to be rendered as a drop down box

See Also:
Constant Field Values

ATTRIBUTE_CHECKBOX

public static final String ATTRIBUTE_CHECKBOX
The Input is intended to be rendered as a check box

See Also:
Constant Field Values

ATTRIBUTE_CHECKBOX_VERTICAL

public static final String ATTRIBUTE_CHECKBOX_VERTICAL
The Input is intended to be rendered as a vertically aligned checkbox

See Also:
Constant Field Values

ATTRIBUTE_RADIO

public static final String ATTRIBUTE_RADIO
The Input is intended to be rendered as a Radio Button

See Also:
Constant Field Values

ATTRIBUTE_RADIO_VERTICAL

public static final String ATTRIBUTE_RADIO_VERTICAL
The Input is intended to be rendered as a Vertically Aligned Radio Button

See Also:
Constant Field Values

ATTRIBUTE_TEXTAREA

public static final String ATTRIBUTE_TEXTAREA
The Input is intended to be rendered as a Text Area

See Also:
Constant Field Values

ATTRIBUTE_HIDDEN

public static final String ATTRIBUTE_HIDDEN
The Input is intended to be rendered as a Hidden Field

See Also:
Constant Field Values

ATTRIBUTE_READONLY

public static final String ATTRIBUTE_READONLY
The Input is intended to be read only.

See Also:
Constant Field Values

ATTRIBUTE_FILE

public static final String ATTRIBUTE_FILE
The Input is indended to be a file upload box.

See Also:
Constant Field Values

ATTRIBUTE_PASSWORD

public static final String ATTRIBUTE_PASSWORD
Attribute for password boxes.

See Also:
Constant Field Values

ATTRIBUTE_ORIGINAL_VALUE

public static final String ATTRIBUTE_ORIGINAL_VALUE
Attribute that contains the original value of this input. Usually set for read only inputs.

See Also:
Constant Field Values

ATTRIBUTE_CSS_STYLE

public static final String ATTRIBUTE_CSS_STYLE
Defines the CSS style to use when rendering the input.

See Also:
Constant Field Values

ATTRIBUTE_MULTIVALUED

public static final String ATTRIBUTE_MULTIVALUED
Means that the Input will be some sort of multi-valued field and has valid values associated with it.

See Also:
Constant Field Values

ATTRIBUTE_TEXTLINE

public static final String ATTRIBUTE_TEXTLINE
text input, single line (as opposed to text area)

See Also:
Constant Field Values

ATTRIBUTE_TYPE

public static final String ATTRIBUTE_TYPE
Attribute defines the HTML Type that will be used with the Input

See Also:
Constant Field Values
Constructor Detail

Input

public Input()
Default constructor


Input

public Input(String newName)
Convenience constructor - to make a new Input object with a specific name

Parameters:
newName - the new input name

Input

public Input(String newName,
             String newLabel)
Constructor that sets the name and the label of the input

Parameters:
newName - the name of the Input
newLabel - the label of the input
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Clones the input as per standard java.lang.Object specifications

Overrides:
clone in class ControllerElement
Returns:
java.lang.Object which is actually an Input.
Throws:
CloneNotSupportedException - as per the API spec.

getDefaultValue

public String getDefaultValue()
Return a single default value supplied by the Controller for this Input object; returns the 0th item in list (we expect this function to be used only for single selection items)

Returns:
A String to be used as the default value for this Input; empty string if no default has been set
See Also:
for multiple selections

getContent

public String getContent()
(Convenience for JSTL access, to be parallel with Output) Return a single default value supplied by the Controller for this Input object; returns the 0th item in list (we expect this function to be used only for single selection items)

Returns:
A String to be used as the default value for this Input; empty string if no default has been set
See Also:
for multiple selections

getDefaultValueList

public ArrayList getDefaultValueList()
Return a list of default values supplied by the Controller for this Input object; appropriate for multiple selection items

Returns:
A list of strings to be used as the default values for this Input; never null, though list can be empty
See Also:
for single selections

getLookup

public String getLookup()
Returns the class name of a database object that can be used to look up valid values for this Input item, if there is one.

Returns:
java.lang.String the class name of the lookup database object

getMaxLength

public int getMaxLength()
Return the maximum recommended length of the value for this Input object.

Returns:
The maximum number of characters that should be supplied * as a value to this Input object

toXML

public FastStringBuffer toXML(FastStringBuffer stream)
Concert the object to an xml fragment.

Overrides:
toXML in class ControllerElement
Parameters:
stream - A FastStringBuffer to append the data to.
Returns:
FastStringBuffer( usually the same one passed in)

fromXML

public static ControllerElement fromXML(org.w3c.dom.Node n)
                                 throws ControllerException
Return a controller element based upon the xml fragment [Factory Method]

Parameters:
n - A DOM node to assemble this Input from.
Returns:
a constructed ControllerElement [Really an Input]
Throws:
ControllerException - if there was a parsing error. (ie malformed nodes)
ControllerException - upon error

getValidValues

public Vector getValidValues()
Return the list of Valid Values that are allowed for this Input item.

Returns:
A Vector of value/description pairs that enumerate * the valid values for this Input item. The user is expected * to select one of these values, but the presentation of the * list is up to the client (e.g. could be a drop-down, radio * buttons, etc). Can be empty, but Never null.

setDefaultValue

public void setDefaultValue(String newValue)
supply a default value for this Input object; appropriate for single selection items; sets the 0th item in underlying list

Parameters:
newValue - The new default value for this Input item
See Also:
for multiple selection

setDefaultValue

public void setDefaultValue(List list)
supply a list of default values for this Input object; appropriate for multiple selection items

Parameters:
list - The new list of default values (strings) for this Input item
See Also:
for adding multiple selection defaults one at a time

addDefaultValue

public void addDefaultValue(String newValue)
supply another default value for this Input object; appropriate for multiple selection items

Parameters:
newValue - The new default value for this Input item
See Also:
for single selection

setDefaultValue

public void setDefaultValue(ControllerResponse response)
                     throws ControllerException
Convenience method to quickly set the default value from the form cache.

Parameters:
response - The controller response where the form cache may exist
Throws:
ControllerException - upon error

setLookup

public void setLookup(String s)
Set the name of the "lookup object" - the database object that the client can use to look up valid values for this Input item.

Parameters:
s - the lookup class name to associate with the Input

setMaxLength

public void setMaxLength(int newMaxLength)
Set the maximum recommended length of the Input object

Parameters:
newMaxLength - Specify the max length (in chars) for this * input item's value.

setName

public void setName(String newName)
Sets the inputs name. Also checks against reserved words

Overrides:
setName in class ControllerElement
Parameters:
newName - the new name for the Input
Throws:
IllegalArgumentException - if the name is a 'reserved word' as defined by ConfigManager.

addValidValue

public void addValidValue(String value,
                          String descrip)
Add a valid value to the Input's dropdown

Parameters:
value - the 'key' part of the valid value
descrip - the description part of the valid value.

setType

public void setType(String newType)
Sets the input type

Overrides:
setType in class ControllerElement
Parameters:
newType - the new type as appears in an Input tag

setValidValues

public void setValidValues(Vector v)
Method for the Controller to specify the valid values for this Input item

Parameters:
v - The value/description pairs that make up the * valid values for this Input object.

setKey

public void setKey(String newKey)
The Key of the Input

Parameters:
newKey - the new value

getKey

public String getKey()
Retrieve the key for the input.

Specified by:
getKey in interface Cacheable
Returns:
java.lang.String

setMultiple

public void setMultiple(String newMultiple)
Set the the Input object allow multiple selections

Parameters:
newMultiple - Specify if true or false the input will accept multiple selects.

getMultiple

public String getMultiple()
Retrieve the multi select status.

Returns:
java.lang.String

getSelectedDisplay

public String getSelectedDisplay()
get the display string associated with the currently-selected (default). useful for a JSTL reuse of Input for output purposes, when the default value is an ID, while its partner ValidValue pairing is the display string.

Returns:
the display string associated with the currently-selected (default) value, or empty string if none found--never null

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.