org.mentawai.ajax
Class AjaxConsequence

java.lang.Object
  extended by org.mentawai.ajax.AjaxConsequence
All Implemented Interfaces:
Consequence

public class AjaxConsequence
extends java.lang.Object
implements Consequence

Author:
Rubem Azenha (rubem.azenha@gmail.com)

A Consequence for using Asynchronous JavaScript And XML, also know as Ajax. This consequence must receive an AjaxRender in its constructor. The AjaxRender is responsible for getting the action result and renderize it into a AjaxResponse implementation.

Each implementation of the AjaxRender can expect diferents values in the action`s output and generates differents text results. The result could be a XML structure, a JSON object, a HTML or even a simple text.

This consequence gets the rendered String and write it`s content to the client.

Then you can use your favorite JavaScript Ajax library (or use your own library) to parse the generated result and interact it in your code.


Field Summary
static java.lang.String DEFAULT_CHARSET
           
static java.lang.String KEY
           
 
Constructor Summary
AjaxConsequence(AjaxRenderer renderer)
           
AjaxConsequence(AjaxRenderer renderer, boolean pretty)
           
AjaxConsequence(java.lang.String key, AjaxRenderer renderer)
           
AjaxConsequence(java.lang.String key, AjaxRenderer renderer, boolean pretty)
           
 
Method Summary
 void execute(Action a, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Prints in the request's output the ajax response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY

public static java.lang.String KEY

DEFAULT_CHARSET

public static java.lang.String DEFAULT_CHARSET
Constructor Detail

AjaxConsequence

public AjaxConsequence(AjaxRenderer renderer)

AjaxConsequence

public AjaxConsequence(java.lang.String key,
                       AjaxRenderer renderer)

AjaxConsequence

public AjaxConsequence(AjaxRenderer renderer,
                       boolean pretty)

AjaxConsequence

public AjaxConsequence(java.lang.String key,
                       AjaxRenderer renderer,
                       boolean pretty)
Method Detail

execute

public void execute(Action a,
                    javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws ConsequenceException
Prints in the request's output the ajax response. The ajax response is supplied by the AjaxRender.

Specified by:
execute in interface Consequence
Parameters:
a - The action that generated this consequence.
req - The servlet request of the action.
res - The servlet response of the action.
Throws:
ConsequenceException


Copyright © 2005 Mentawai Team. All Rights Reserved.