org.araneaframework.uilib.form.control
Class FloatControl

java.lang.Object
  extended byorg.araneaframework.core.BaseComponent
      extended byorg.araneaframework.core.BaseService
          extended byorg.araneaframework.core.BaseWidget
              extended byorg.araneaframework.core.BaseApplicationWidget
                  extended byorg.araneaframework.uilib.form.control.BaseControl
                      extended byorg.araneaframework.uilib.form.control.StringArrayRequestControl
                          extended byorg.araneaframework.uilib.form.control.StringRequestControl
                              extended byorg.araneaframework.uilib.form.control.EmptyStringNullableControl
                                  extended byorg.araneaframework.uilib.form.control.FloatControl
All Implemented Interfaces:
ApplicationComponent, ApplicationService, ApplicationWidget, Component, Composite, Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, Control, FilteredInputControl, FormElementAware, Serializable, Service, Viewable, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget, Widget

public class FloatControl
extends EmptyStringNullableControl
implements FilteredInputControl

This class represents a textbox control that accepts only valid floating-point numbers. This class does not support localization. It does not use @link NumberFormat class to parse and format @link BigDecimal objects because @link NumberFormat would convert @link BigDecimal objects into doubles. To customize parsing and formatting one could create a subclass of it and override @link #createBigDecimal(String) and @link #toString(BigDecimal) methods. To use the subclass in JSPs also another JSP Tag must be created to use this implementation and configure validation script.

Author:
Jevgeni Kabanov (ekabanov at araneaframework dot org), Rein Raudjärv
See Also:
Serialized Form

Nested Class Summary
 class FloatControl.ViewModel
           
 
Nested classes inherited from class org.araneaframework.uilib.form.control.BaseControl
BaseControl.WidgetImpl
 
Nested classes inherited from class org.araneaframework.core.BaseApplicationWidget
BaseApplicationWidget.CompositeImpl, BaseApplicationWidget.ViewableImpl
 
Nested classes inherited from class org.araneaframework.core.BaseService
BaseService.ServiceImpl
 
Nested classes inherited from class org.araneaframework.core.BaseComponent
BaseComponent.ComponentImpl
 
Nested classes inherited from class org.araneaframework.Widget
Widget.Interface
 
Nested classes inherited from class org.araneaframework.Viewable
Viewable.Interface, Viewable.ViewableComponent, Viewable.ViewableService, Viewable.ViewableWidget
 
Nested classes inherited from class org.araneaframework.core.ApplicationWidget
ApplicationWidget.WidgetViewModel
 
Nested classes inherited from class org.araneaframework.core.ApplicationService
ApplicationService.ServiceViewModel
 
Nested classes inherited from class org.araneaframework.core.ApplicationComponent
ApplicationComponent.ComponentViewModel
 
Nested classes inherited from class org.araneaframework.Composite
Composite.CompositeComponent, Composite.CompositeService, Composite.CompositeWidget, Composite.Interface
 
Field Summary
 
Fields inherited from class org.araneaframework.uilib.form.control.StringArrayRequestControl
eventHelper
 
Fields inherited from class org.araneaframework.uilib.form.control.BaseControl
innerData, isReadFromRequest, value
 
Fields inherited from class org.araneaframework.core.BaseService
currentInputData, currentOutputData
 
Fields inherited from interface org.araneaframework.core.ApplicationWidget
EVENT_HANDLER_ID_KEY, EVENT_PARAMETER_KEY, EVENT_PATH_KEY
 
Fields inherited from interface org.araneaframework.core.ApplicationService
ACTION_HANDLER_ID_KEY, ACTION_PARAMETER_KEY, ACTION_PATH_KEY
 
Constructor Summary
FloatControl()
          Empty.
FloatControl(BigDecimal minValue, BigDecimal maxValue)
          Makes a float control that has minimum and maximum value.
FloatControl(BigDecimal minValue, BigDecimal maxValue, Integer maxScale)
          Makes a float control that has minimum, maximum value and maximum scale.
 
Method Summary
protected  BigDecimal createBigDecimal(String str)
          Converts String into BigDecimal.
protected  Object fromRequest(String parameterValue)
          Checks that the submitted data is a valid floating-point number.
 InputFilter getInputFilter()
           
 Integer getMaxScale()
          Returns the maximum scale.
 BigDecimal getMaxValue()
          Returns the maxValue.
 BigDecimal getMinValue()
          Returns the minValue.
 String getRawValueType()
          Returns "BigDecimal".
 Object getViewModel()
          Returns FloatControl.ViewModel.
protected  String preprocessRequestParameter(String parameterValue)
          Trims request parameter.
 void setInputFilter(InputFilter inputFilter)
           
 void setMaxScale(Integer maxScale)
          Sets the maximum scale.
 void setMaxValue(BigDecimal maxValue)
          Sets the maximum value.
 void setMinValue(BigDecimal minValue)
          Sets the minimum value.
protected  String toResponse(Object controlValue)
           
protected  String toString(BigDecimal dec)
          Converts BigDecimal into String.
protected  void validateNotNull()
          Checks that the submitted value is in permitted range.
 
Methods inherited from class org.araneaframework.uilib.form.control.EmptyStringNullableControl
isRead
 
Methods inherited from class org.araneaframework.uilib.form.control.StringRequestControl
fromRequestParameters, preprocessRequestParameters, toResponseParameters
 
Methods inherited from class org.araneaframework.uilib.form.control.StringArrayRequestControl
addOnChangeEventListener, clearOnChangeEventListeners, convert, init, readFromRequest, setRawValue, validate
 
Methods inherited from class org.araneaframework.uilib.form.control.BaseControl
_getWidget, action, addError, convertAndValidate, getFormElementCtx, getLabel, getRawValue, handleEvent, isDisabled, isMandatory, isValid, setFormElementCtx, update
 
Methods inherited from class org.araneaframework.core.BaseApplicationWidget
_getComposite, _getViewable, addActionListener, addEventListener, addWidget, addWidget, clearActionListeners, clearEventlisteners, clearGlobalEventListener, disableWidget, enableWidget, event, getActionId, getChildEnvironment, getChildren, getChildWidgetEnvironment, getEnvironment, getEventId, getWidget, handleAction, handleUpdate, propagate, putViewData, putViewDataOnce, removeActionListener, removeEventListener, removeViewData, removeWidget, render, setGlobalEventListener
 
Methods inherited from class org.araneaframework.core.BaseWidget
getInputData, getOutputData, handleWidgetException
 
Methods inherited from class org.araneaframework.core.BaseService
_getService, handleServiceException
 
Methods inherited from class org.araneaframework.core.BaseComponent
_addComponent, _addComponent, _checkCall, _disableComponent, _enableComponent, _endCall, _endWaitingCall, _getChildren, _getComponent, _getDisabledChildren, _propagate, _relocateComponent, _removeComponent, _setEnvironment, _setScope, _startCall, _startWaitingCall, _strictCheckCall, _strictStartCall, _waitNoCall, destroy, disable, enable, getScope, handleException, isAlive, isDead, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.araneaframework.uilib.form.Control
convert, getRawValue, isDisabled, isRead, setRawValue, validate
 
Methods inherited from interface org.araneaframework.Widget
_getWidget
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Component
_getComponent, getEnvironment, getScope, isAlive
 
Methods inherited from interface org.araneaframework.Viewable
_getViewable
 
Methods inherited from interface org.araneaframework.uilib.form.FormElementAware
setFormElementCtx
 

Constructor Detail

FloatControl

public FloatControl()
Empty.


FloatControl

public FloatControl(BigDecimal minValue,
                    BigDecimal maxValue,
                    Integer maxScale)
Makes a float control that has minimum, maximum value and maximum scale.

Parameters:
minValue - minimum permitted value.
maxValue - maximum permitted value.
maxScale - maximum permitted scale.

FloatControl

public FloatControl(BigDecimal minValue,
                    BigDecimal maxValue)
Makes a float control that has minimum and maximum value.

Parameters:
minValue - minimum permitted value.
maxValue - maximum permitted value.
Method Detail

setMaxValue

public void setMaxValue(BigDecimal maxValue)
Sets the maximum value.

Parameters:
maxValue - maximum value.

setMinValue

public void setMinValue(BigDecimal minValue)
Sets the minimum value.

Parameters:
minValue - minimum value.

setMaxScale

public void setMaxScale(Integer maxScale)
Sets the maximum scale.

Parameters:
maxScale - maximum scale.

getMaxValue

public BigDecimal getMaxValue()
Returns the maxValue.

Returns:
the maxValue.

getMinValue

public BigDecimal getMinValue()
Returns the minValue.

Returns:
the minValue.

getMaxScale

public Integer getMaxScale()
Returns the maximum scale.

Returns:
the maximum scale.

getRawValueType

public String getRawValueType()
Returns "BigDecimal".

Specified by:
getRawValueType in interface Control
Returns:
"BigDecimal".

getInputFilter

public InputFilter getInputFilter()
Specified by:
getInputFilter in interface FilteredInputControl
Since:
1.0.11

setInputFilter

public void setInputFilter(InputFilter inputFilter)
Specified by:
setInputFilter in interface FilteredInputControl
Since:
1.0.11

preprocessRequestParameter

protected String preprocessRequestParameter(String parameterValue)
Trims request parameter.

Overrides:
preprocessRequestParameter in class EmptyStringNullableControl

fromRequest

protected Object fromRequest(String parameterValue)
Checks that the submitted data is a valid floating-point number.

Specified by:
fromRequest in class StringRequestControl
See Also:
StringArrayRequestControl.fromRequestParameters(String[])

toResponse

protected String toResponse(Object controlValue)
Specified by:
toResponse in class StringRequestControl
See Also:
StringArrayRequestControl.toResponseParameters(Object)

createBigDecimal

protected BigDecimal createBigDecimal(String str)
                               throws NumberFormatException
Converts String into BigDecimal. This method can be overrided in subclasses.

Parameters:
str - String object
Returns:
BigDecimal object
Throws:
NumberFormatException - str is not a valid representation of a BigDecimal

toString

protected String toString(BigDecimal dec)
Converts BigDecimal into String. This method can be overrided in subclasses.

Parameters:
dec - BigDecimal object
Returns:
String object

validateNotNull

protected void validateNotNull()
Checks that the submitted value is in permitted range.

Overrides:
validateNotNull in class StringArrayRequestControl

getViewModel

public Object getViewModel()
Returns FloatControl.ViewModel.

Overrides:
getViewModel in class StringArrayRequestControl
Returns:
FloatControl.ViewModel.