org.jreform.internal
Class AbstractInputControl<T>

java.lang.Object
  extended by org.jreform.internal.AbstractInputControl<T>
All Implemented Interfaces:
InputControl<T>, MessageOnError
Direct Known Subclasses:
InputImpl, MultiInputImpl

abstract class AbstractInputControl<T>
extends Object
implements InputControl<T>

Base class for single- and multi-value input controls. Validation rules are implemented by subclasses.

Author:
armandino (at) gmail.com

Field Summary
private  Criterion<T>[] criteria
           
private  boolean isGroupInput
           
private  boolean isRequired
           
private  boolean isValid
           
private  String messageOnError
           
private  String name
           
private  InputDataType<T> type
           
 
Constructor Summary
AbstractInputControl(InputDataType<T> type, String name, Criterion<T>... criteria)
          Constructor.
 
Method Summary
protected  Criterion<T>[] getCriteria()
           
 String getInputName()
          Returns this input's name attribute.
 String getOnError()
          Returns a message describing an error or an empty string if there was no error.
 InputDataType<T> getType()
          Returns this input's data type.
(package private)  boolean isGroupInput()
          Returns true if this input belongs to a group.
 boolean isRequired()
          Returns true if this input must have a value.
 boolean isValid()
          Returns true if this input's data is valid.
(package private)  void setGroupInput(boolean isGroupInput)
           
 void setOnError(String message)
          Sets a message to be displayed on error.
(package private)  void setRequired(boolean isRequired)
           
(package private)  void setValid(boolean isValid)
           
(package private) abstract  boolean validate(javax.servlet.http.HttpServletRequest req)
          Validates this input's value attribute(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jreform.InputControl
getStringValue
 

Field Detail

type

private InputDataType<T> type

name

private String name

messageOnError

private String messageOnError

isRequired

private boolean isRequired

isValid

private boolean isValid

isGroupInput

private boolean isGroupInput

criteria

private Criterion<T>[] criteria
Constructor Detail

AbstractInputControl

AbstractInputControl(InputDataType<T> type,
                     String name,
                     Criterion<T>... criteria)
Constructor.

Parameters:
type - of this input's data.
name - of this input.
isRequired - is this a required or optional input field.
criteria - this input's data must satisfy.
Method Detail

validate

abstract boolean validate(javax.servlet.http.HttpServletRequest req)
Validates this input's value attribute(s).


getType

public final InputDataType<T> getType()
Description copied from interface: InputControl
Returns this input's data type.

Specified by:
getType in interface InputControl<T>

getInputName

public final String getInputName()
Description copied from interface: InputControl
Returns this input's name attribute.

Specified by:
getInputName in interface InputControl<T>

getOnError

public final String getOnError()
Description copied from interface: MessageOnError
Returns a message describing an error or an empty string if there was no error.

Specified by:
getOnError in interface MessageOnError

setOnError

public final void setOnError(String message)
Description copied from interface: MessageOnError
Sets a message to be displayed on error.

Specified by:
setOnError in interface MessageOnError

isRequired

public final boolean isRequired()
Description copied from interface: InputControl
Returns true if this input must have a value.

Specified by:
isRequired in interface InputControl<T>

setRequired

final void setRequired(boolean isRequired)

isValid

public final boolean isValid()
Description copied from interface: InputControl
Returns true if this input's data is valid.

Specified by:
isValid in interface InputControl<T>

setValid

final void setValid(boolean isValid)

isGroupInput

final boolean isGroupInput()
Returns true if this input belongs to a group.


setGroupInput

final void setGroupInput(boolean isGroupInput)

getCriteria

protected final Criterion<T>[] getCriteria()


Copyright © 2007-2008 jReform