net.sourceforge.stripes.examples.ajax
Class CalculatorActionBean

java.lang.Object
  extended by net.sourceforge.stripes.examples.ajax.CalculatorActionBean
All Implemented Interfaces:
net.sourceforge.stripes.action.ActionBean, net.sourceforge.stripes.validation.ValidationErrorHandler

public class CalculatorActionBean
extends Object
implements net.sourceforge.stripes.action.ActionBean, net.sourceforge.stripes.validation.ValidationErrorHandler

A very simple calculator action that is designed to work with an ajax front end. Handles 'add' and 'divide' events just like the non-ajax calculator. Each event calculates the result, and then "streams" it back to the browser. Implements the ValidationErrorHandler interface to intercept any validation errors, convert them to an HTML message and stream the back to the browser for display.

Author:
Tim Fennell

Constructor Summary
CalculatorActionBean()
           
 
Method Summary
 net.sourceforge.stripes.action.Resolution add()
          Handles the 'add' event, adds the two numbers and returns the result.
 net.sourceforge.stripes.action.Resolution divide()
          Handles the 'divide' event, divides number two by oneand returns the result.
 net.sourceforge.stripes.action.ActionBeanContext getContext()
           
 double getNumberOne()
           
 double getNumberTwo()
           
 net.sourceforge.stripes.action.Resolution handleValidationErrors(net.sourceforge.stripes.validation.ValidationErrors errors)
          Converts errors to HTML and streams them back to the browser.
 void setContext(net.sourceforge.stripes.action.ActionBeanContext context)
           
 void setNumberOne(double numberOne)
           
 void setNumberTwo(double numberTwo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalculatorActionBean

public CalculatorActionBean()
Method Detail

getContext

public net.sourceforge.stripes.action.ActionBeanContext getContext()
Specified by:
getContext in interface net.sourceforge.stripes.action.ActionBean

setContext

public void setContext(net.sourceforge.stripes.action.ActionBeanContext context)
Specified by:
setContext in interface net.sourceforge.stripes.action.ActionBean

handleValidationErrors

public net.sourceforge.stripes.action.Resolution handleValidationErrors(net.sourceforge.stripes.validation.ValidationErrors errors)
                                                                 throws Exception
Converts errors to HTML and streams them back to the browser.

Specified by:
handleValidationErrors in interface net.sourceforge.stripes.validation.ValidationErrorHandler
Throws:
Exception

add

@DefaultHandler
public net.sourceforge.stripes.action.Resolution add()
Handles the 'add' event, adds the two numbers and returns the result.


divide

public net.sourceforge.stripes.action.Resolution divide()
Handles the 'divide' event, divides number two by oneand returns the result.


getNumberOne

public double getNumberOne()

setNumberOne

public void setNumberOne(double numberOne)

getNumberTwo

public double getNumberTwo()

setNumberTwo

public void setNumberTwo(double numberTwo)


© Copyright 2005, Stripes Development Team.