|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.forms.formmodel.AbstractWidget org.apache.cocoon.forms.formmodel.Field org.apache.cocoon.forms.formmodel.CalculatedField
public class CalculatedField
A field which calculates its value.
A calculated field is useful to create fields containing a sum, or a percentage, or any other value derived from other fields in the form.
The way the field calculates its value is determined by its
CalculatedFieldAlgorithm
.
The algorithm is also responsible for determining which other form widgets will trigger
a value calculation for this field.
Field Summary |
---|
Fields inherited from class org.apache.cocoon.forms.formmodel.Field |
---|
enteredValue, required, selectionList, SUGGESTED_LABEL_ATTR, suggestionList, validationError, value, VALUE_DISPLAY_PARSE_ERROR, VALUE_DISPLAY_VALIDATION, VALUE_PARSE_ERROR, VALUE_PARSED, VALUE_UNPARSED, VALUE_VALIDATED, VALUE_VALIDATING, valueState |
Fields inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget |
---|
wasValid |
Fields inherited from interface org.apache.cocoon.forms.formmodel.Widget |
---|
PATH_SEPARATOR |
Constructor Summary | |
---|---|
protected |
CalculatedField(CalculatedFieldDefinition definition)
|
Method Summary | |
---|---|
protected Object |
convert(Object ret,
Datatype datatype)
Tries to convert the return value of the algorithm to the right value for this field datatype. |
CalculatedFieldAlgorithm |
getAlgorithm()
|
Object |
getValue()
Get the value of a widget. |
void |
initialize()
Called after widget's environment has been setup, to allow for any contextual initalization, such as looking up case widgets for union widgets. |
protected void |
installHandlers()
Installs handlers on other widgets. |
protected void |
readFromRequest(String newEnteredValue)
|
protected Object |
recalculate()
Calls the algorithm to perform a recaulculation. |
Methods inherited from class org.apache.cocoon.forms.formmodel.Field |
---|
addValueChangedListener, applyWhitespaceTrim, broadcastEvent, generateItemSaxFragment, getDatatype, getDefinition, getFieldDefinition, getSuggestionLabel, getSuggestionList, getValidationError, getXMLElementAttributes, getXMLElementName, hasValueChangedListeners, isRequired, isSuggested, readFromRequest, removeValueChangedListener, setRequired, setSelectionList, setSelectionList, setSelectionList, setSuggestionLabel, setSuggestionList, setSuggestionList, setValidationError, setValue, validate |
Methods inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget |
---|
addValidator, generateDisplayData, generateLabel, generateSaxFragment, getAttribute, getChild, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getWidget, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, toString, widgetNameChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.cocoon.forms.formmodel.Widget |
---|
addValidator, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getWidget, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState |
Constructor Detail |
---|
protected CalculatedField(CalculatedFieldDefinition definition)
definition
- Method Detail |
---|
public void initialize()
AbstractWidget
initialize
in interface Widget
initialize
in class Field
protected void installHandlers()
protected void readFromRequest(String newEnteredValue)
readFromRequest
in class Field
public Object getValue()
Widget
Not all widgets do have a value (notably ContainerWidget
s,
but this method is provided here as a convenience to ease writing and avoiding casts.
getValue
in interface Widget
getValue
in class Field
protected Object recalculate()
protected Object convert(Object ret, Datatype datatype) throws Exception
ret
- The return value fo the algorithm.datatype
- The target datatype.
Exception
public CalculatedFieldAlgorithm getAlgorithm()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |