net.sourceforge.stripes.ajax
Class JavaScriptResolution

java.lang.Object
  extended by net.sourceforge.stripes.ajax.JavaScriptResolution
All Implemented Interfaces:
Resolution

public class JavaScriptResolution
extends Object
implements Resolution

Resolution that will convert a Java object web to a web of JavaScript objects and arrays, and stream the JavaScript back to the client. The output of this resolution can be evaluated in JavaScript using the eval() function, and will return a reference to the top level JavaScript object. For more information see JavaScriptBuilder

Since:
Stripes 1.1
Author:
Tim Fennell

Constructor Summary
JavaScriptResolution(Object rootObject, Object... objectsToExclude)
          Constructs a new JavaScriptResolution that will convert the supplied object to JavaScript.
 
Method Summary
 JavaScriptResolution addClassExclusion(Class<?>... clazz)
          Adds one or more classes to the list of types to exclude when translating to JavaScript.
 JavaScriptResolution addPropertyExclusion(String... property)
          Adds one or more properties to the list of types to exclude when translating to JavaScript.
 void execute(HttpServletRequest request, HttpServletResponse response)
          Converts the object passed in to JavaScript and streams it back to the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaScriptResolution

public JavaScriptResolution(Object rootObject,
                            Object... objectsToExclude)
Constructs a new JavaScriptResolution that will convert the supplied object to JavaScript.

Parameters:
rootObject - an Object of any type supported by JavaScriptBuilder. In most cases this will either be a JavaBean, Map, Collection or Array, but may also be any one of the basic Java types including String, Date, Number etc.
objectsToExclude - Classes and/or property names to exclude from the output.
Method Detail

addPropertyExclusion

public JavaScriptResolution addPropertyExclusion(String... property)
Adds one or more properties to the list of types to exclude when translating to JavaScript.

Parameters:
property - one or more property names to exclude
Returns:
the JavaScripResolution instance to simplify method chaining

addClassExclusion

public JavaScriptResolution addClassExclusion(Class<?>... clazz)
Adds one or more classes to the list of types to exclude when translating to JavaScript.

Parameters:
clazz - one or more classes to exclude
Returns:
the JavaScripResolution instance to simplify method chaining

execute

public void execute(HttpServletRequest request,
                    HttpServletResponse response)
             throws Exception
Converts the object passed in to JavaScript and streams it back to the client.

Specified by:
execute in interface Resolution
Parameters:
request - the current HttpServletRequest
response - the current HttpServletResponse
Throws:
Exception - exceptions of any type may be thrown if the Resolution cannot be executed as intended


© Copyright 2005-2006, Stripes Development Team.