org.apache.empire.struts2.jsp.controls
Class InputControl

java.lang.Object
  extended by org.apache.empire.struts2.jsp.controls.InputControl
Direct Known Subclasses:
CheckboxInputControl, PasswordInputControl, PhoneInputControl, RadioInputControl, SelectInputControl, TextAreaInputControl, TextInputControl

public abstract class InputControl
extends Object


Nested Class Summary
static interface InputControl.ControlInfo
          This interface extends the value information by information about the input control used with the renderInput function
static class InputControl.FieldValueError
          This class wraps a parsing or validation error.
static interface InputControl.ValueInfo
          This interface allows access to a value and its metainformation used with the renderData function
 
Field Summary
static String CURRENCY_CODE_ATTRIBUTE
           
static String FILE_DATA_COLUMN_ATTRIBUTE
           
protected static org.slf4j.Logger log
           
static String MAXVALUE_ATTRIBUTE
           
static String MINVALUE_ATTRIBUTE
           
static Object NO_VALUE
          The NO_VALUE constant is used as a return value from getFieldValue to indicate that the value for this column has not been provided
static Object NULL_VALUE
          The NULL_VALUE constant is used as a return value from getFieldValue to indicate that the field value was provided with the request, but is empty so that the underlying database field should be set to null
static String NUMBER_FORMAT_ATTRIBUTE
           
static String NUMBER_FRACTION_DIGITS
           
static String NUMBER_GROUPSEP_ATTRIBUTE
           
 
Constructor Summary
InputControl()
           
 
Method Summary
protected  InputControl.FieldValueError error(ErrorType errorType, Object msgParam, String value)
           
protected  InputControl.FieldValueError error(ErrorType errorType, String[] msgParams, String value)
          This method can be used to return a parsing or validation error To be used in the getFieldValue, the parseValue or the validate function.
protected  String formatValue(InputControl.ValueInfo vi)
          Returns the value formated as a string This is a shortcut for formatString(vi.getValue(), vi) Derived classes may override formatString
protected  String formatValue(Object value, InputControl.ValueInfo vi, boolean hasError)
          Returns the value formated as a string this is a simple default implementation that does no type-secific formatting Derived classes may override formatString an provide further formmatting see TextInputControl for details
 Object getFieldValue(String name, RequestParamProvider request, Locale locale, Column column)
          this method parses and validates the value of a particular column from the request
protected  String getFormatOption(InputControl.ValueInfo vi, String option)
           
protected  boolean hasFormatOption(InputControl.ValueInfo vi, String option)
          checks if a particular formating option has been specified.
protected  void internalRenderText(HtmlWriter writer, InputControl.ValueInfo vi)
          this method renders a record value read only it is internally called by renderText
protected  Object parseValue(String value, Locale locale, Column column)
          this function may be overridden to parse and convert the input value to the data type of the supplied column
protected  void printText(HtmlWriter writer, String text, String defaultValue)
          writes out plain text to the output stream if the text supplied is null or an empty String then a   is written
abstract  void renderInput(HtmlWriter writer, InputControl.ControlInfo ci)
          this method renders a record value for input
 void renderText(HtmlWriter writer, InputControl.ValueInfo vi)
          this method renders a record value read only this can be either in a read only form or a table
 boolean useLabelId()
          This method determines whether an id should be put on the input label If true than the renderInput function must add an id attribute to an input field The value of the id is supplied with the ControlInfo
protected  Object validate(Object value, Locale locale, Column column, String s)
          this function may be overridden to validate a value that has previously been parsed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.slf4j.Logger log

NUMBER_FORMAT_ATTRIBUTE

public static final String NUMBER_FORMAT_ATTRIBUTE
See Also:
Constant Field Values

NUMBER_GROUPSEP_ATTRIBUTE

public static final String NUMBER_GROUPSEP_ATTRIBUTE
See Also:
Constant Field Values

NUMBER_FRACTION_DIGITS

public static final String NUMBER_FRACTION_DIGITS
See Also:
Constant Field Values

MINVALUE_ATTRIBUTE

public static final String MINVALUE_ATTRIBUTE
See Also:
Constant Field Values

MAXVALUE_ATTRIBUTE

public static final String MAXVALUE_ATTRIBUTE
See Also:
Constant Field Values

CURRENCY_CODE_ATTRIBUTE

public static final String CURRENCY_CODE_ATTRIBUTE
See Also:
Constant Field Values

FILE_DATA_COLUMN_ATTRIBUTE

public static final String FILE_DATA_COLUMN_ATTRIBUTE
See Also:
Constant Field Values

NO_VALUE

public static final Object NO_VALUE
The NO_VALUE constant is used as a return value from getFieldValue to indicate that the value for this column has not been provided


NULL_VALUE

public static final Object NULL_VALUE
The NULL_VALUE constant is used as a return value from getFieldValue to indicate that the field value was provided with the request, but is empty so that the underlying database field should be set to null

Constructor Detail

InputControl

public InputControl()
Method Detail

error

protected final InputControl.FieldValueError error(ErrorType errorType,
                                                   String[] msgParams,
                                                   String value)
This method can be used to return a parsing or validation error To be used in the getFieldValue, the parseValue or the validate function. It is a shortcut for writing return error(InputErrors.xxxx, null, value) instead of return new FieldValueError(InputErrors.xxxx, null, value, getClass());

Returns:
the field Error Object

error

protected final InputControl.FieldValueError error(ErrorType errorType,
                                                   Object msgParam,
                                                   String value)

useLabelId

public boolean useLabelId()
This method determines whether an id should be put on the input label If true than the renderInput function must add an id attribute to an input field The value of the id is supplied with the ControlInfo

Returns:
true if an id should be set on the label or false otherwise

getFieldValue

public Object getFieldValue(String name,
                            RequestParamProvider request,
                            Locale locale,
                            Column column)
this method parses and validates the value of a particular column from the request

Parameters:
name - the name under which the param is stored on the request
request - used to access the request Parameters
column - the column for which the value should be
Returns:
the parsed and validated record field value or a FieldValueError if an error occurred

renderText

public void renderText(HtmlWriter writer,
                       InputControl.ValueInfo vi)
this method renders a record value read only this can be either in a read only form or a table

Parameters:
writer - the HtmlWriter for html write-out
vi - Object holding the value and meta-information about the value

renderInput

public abstract void renderInput(HtmlWriter writer,
                                 InputControl.ControlInfo ci)
this method renders a record value for input

Parameters:
writer - the HtmlWriter for html write-out
ci - Object holding the value and meta-information about the value and the control

internalRenderText

protected void internalRenderText(HtmlWriter writer,
                                  InputControl.ValueInfo vi)
this method renders a record value read only it is internally called by renderText

Parameters:
writer - the HtmlWriter for html write-out
vi - Object holding the value and meta-information about the value

printText

protected final void printText(HtmlWriter writer,
                               String text,
                               String defaultValue)
writes out plain text to the output stream if the text supplied is null or an empty String then a   is written

Parameters:
writer - the HtmlWriter for html write-out
text - the text to write

parseValue

protected Object parseValue(String value,
                            Locale locale,
                            Column column)
this function may be overridden to parse and convert the input value to the data type of the supplied column

Parameters:
value - the value string from the request
locale - the user locale
column - the column for which the value is supplied
Returns:
the parsed value

validate

protected Object validate(Object value,
                          Locale locale,
                          Column column,
                          String s)
this function may be overridden to validate a value that has previously been parsed

Parameters:
value - the parsed object value
column - the column for which the value should be validated
s - the unparsed value string. In case of an error this should be forwarded to the error function.
Returns:
the parsed value

formatValue

protected String formatValue(Object value,
                             InputControl.ValueInfo vi,
                             boolean hasError)
Returns the value formated as a string this is a simple default implementation that does no type-secific formatting Derived classes may override formatString an provide further formmatting see TextInputControl for details

Parameters:
value - the value to be formatted
vi - Meta-information about the value
Returns:
the formatted value

formatValue

protected final String formatValue(InputControl.ValueInfo vi)
Returns the value formated as a string This is a shortcut for formatString(vi.getValue(), vi) Derived classes may override formatString


hasFormatOption

protected boolean hasFormatOption(InputControl.ValueInfo vi,
                                  String option)
checks if a particular formating option has been specified.

Parameters:
vi - the value info
option - the formating option to check
Returns:
true if the requested formating option has been specified or false otherwise

getFormatOption

protected String getFormatOption(InputControl.ValueInfo vi,
                                 String option)


Copyright © 2008–2014 Apache Software Foundation. All rights reserved.