net.sf.colle.forms
Class Text

java.lang.Object
  extended bynet.sf.colle.forms.Text
All Implemented Interfaces:
FormElement
Direct Known Subclasses:
Number

public class Text
extends Object
implements FormElement

This class is the text element within a form structure. Created: 10 Jul 2001

Version:
$Revision: 1.2 $, $Date: 2004/12/01 06:58:55 $
Author:
Jeremy Miller

Field Summary
static String ERROR_TOO_LONG
           
static String ERROR_TOO_SHORT
           
 
Fields inherited from interface net.sf.colle.forms.FormElement
ERROR_INVALID, ERROR_REQUIRED, UNKNOWN, VALID
 
Constructor Summary
Text(String psName, Object pxApplicationElement, FormElement pxParent, String psDefaultValue, boolean pbRequired, int pnMinLength, int pnMaxLength)
          Create a new text element.
 
Method Summary
 Object getApplicationElement()
          Returns the application object that corresponds to this form object.
protected  String getDerivedType()
          Allows derived classes to define the type placed to the out-going XML response document.
 String getErrorCode()
          Returns the error code of the element
 String getName()
          Returns the name of the the form element.
 String getPath()
          Returns the path to the form element.
 boolean getRequired()
          Returns the required flag.
 String getText()
          Returns the value as a string
 void map(org.jdom.Element pxElement)
          Maps the element into a DOM document.
 void service(HttpServletRequest pxRequest, org.jdom.Element pxOldValue)
          Process the returing HTTP request.
 void setErrorCode(String psCode)
          Sets the error code.
 void setText(String psValue)
          update the value
 void setToDefault(boolean pbRecursive)
          Return value to the default settings.
 int validate(boolean pbRecursive)
          validate the element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_TOO_SHORT

public static final String ERROR_TOO_SHORT
See Also:
Constant Field Values

ERROR_TOO_LONG

public static final String ERROR_TOO_LONG
See Also:
Constant Field Values
Constructor Detail

Text

public Text(String psName,
            Object pxApplicationElement,
            FormElement pxParent,
            String psDefaultValue,
            boolean pbRequired,
            int pnMinLength,
            int pnMaxLength)
Create a new text element.

Parameters:
psName - name of element
psDefaultValue - initial default value
pbRequired - required element
pnMinLength - minimum length allow
pnMaxLength - maximum length allow
pxParent - path to the parent in the xml tree
Method Detail

map

public void map(org.jdom.Element pxElement)
Maps the element into a DOM document.

Specified by:
map in interface FormElement
Parameters:
pxElement - parent element to add new elements onto

getErrorCode

public String getErrorCode()
Returns the error code of the element

Specified by:
getErrorCode in interface FormElement
Returns:
error code

getName

public String getName()
Description copied from interface: FormElement
Returns the name of the the form element.

Specified by:
getName in interface FormElement
Returns:
the name
See Also:
FormElement

getPath

public String getPath()
Description copied from interface: FormElement
Returns the path to the form element. This path uniquely identifies the data object in the DOM tree and when the object is returned through the form.

Specified by:
getPath in interface FormElement
Returns:
the name
See Also:
FormElement

getApplicationElement

public Object getApplicationElement()
Description copied from interface: FormElement
Returns the application object that corresponds to this form object.

Specified by:
getApplicationElement in interface FormElement
See Also:
FormElement

getRequired

public boolean getRequired()
Returns the required flag. A true means the element requires input to be in a valid state.

Returns:
the required flag

getText

public String getText()
Returns the value as a string

Returns:
the string value

service

public void service(HttpServletRequest pxRequest,
                    org.jdom.Element pxOldValue)
Process the returing HTTP request.

Specified by:
service in interface FormElement
Parameters:
pxRequest - http request to fetch data from
pxOldValue - form element details when the form was sent to the user

setErrorCode

public void setErrorCode(String psCode)
Description copied from interface: FormElement
Sets the error code. JSP's may do this to display an error found outside of built-in validation.

Specified by:
setErrorCode in interface FormElement
Parameters:
psCode - error code
See Also:
FormElement

setText

public void setText(String psValue)
update the value

Parameters:
psValue - new value

setToDefault

public void setToDefault(boolean pbRecursive)
Return value to the default settings.

Specified by:
setToDefault in interface FormElement
Parameters:
pbRecursive - on true set child elements

validate

public int validate(boolean pbRecursive)
validate the element.

Specified by:
validate in interface FormElement
Parameters:
pbRecursive - on true check child elements
Returns:
error count

getDerivedType

protected String getDerivedType()
Allows derived classes to define the type placed to the out-going XML response document.