org.apache.cocoon.forms.formmodel.algorithms
Class JavaScript

java.lang.Object
  extended byorg.apache.cocoon.forms.formmodel.algorithms.JavaScript
All Implemented Interfaces:
CalculatedFieldAlgorithm

public class JavaScript
extends Object
implements CalculatedFieldAlgorithm

Javascript calculated field algorithm.

Version:
$Id: JavaScript.html 1304280 2012-03-23 11:18:01Z ilgrosso $
See Also:
JavaScriptBuilder

Constructor Summary
JavaScript()
           
 
Method Summary
 void addTriggerWidget(String widgetname)
           
 Object calculate(Form form, Widget parent, Datatype datatype)
          Performs the actual calculation.
 org.mozilla.javascript.Function getJsfunction()
           
 Iterator getTriggerWidgets()
          Returns an iterator on trigger widget paths.
 boolean isSuitableFor(Datatype dataType)
          Checks wether this algorithm is able to return the given datatype.
 void setJsfunction(org.mozilla.javascript.Function jsfunction)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScript

public JavaScript()
Method Detail

calculate

public Object calculate(Form form,
                        Widget parent,
                        Datatype datatype)
Description copied from interface: CalculatedFieldAlgorithm
Performs the actual calculation.

Specified by:
calculate in interface CalculatedFieldAlgorithm
Parameters:
form - The form.
parent - The parent widget of the CalculatedField widget (may be the same as form)
datatype - The target datatype.
Returns:
the calculated value for the CalculatedField.

isSuitableFor

public boolean isSuitableFor(Datatype dataType)
Description copied from interface: CalculatedFieldAlgorithm
Checks wether this algorithm is able to return the given datatype. For example, an arithmetic algorithm like sum should check that the given datatype is a number.

Specified by:
isSuitableFor in interface CalculatedFieldAlgorithm
Parameters:
dataType - The target datatype.
Returns:
true if this algorithm can return a compatible value, false otherwise.

getJsfunction

public org.mozilla.javascript.Function getJsfunction()
Returns:
Returns the jsfunction.

setJsfunction

public void setJsfunction(org.mozilla.javascript.Function jsfunction)
Parameters:
jsfunction - The jsfunction to set.

addTriggerWidget

public void addTriggerWidget(String widgetname)

getTriggerWidgets

public Iterator getTriggerWidgets()
Description copied from interface: CalculatedFieldAlgorithm
Returns an iterator on trigger widget paths. When the value of a trigger widget changes, then the CalculatedField value must be recalculated.

Specified by:
getTriggerWidgets in interface CalculatedFieldAlgorithm
Returns:
An iterator of Strings representing widget paths as interpreted by WidgetFinder.


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.