org.mentawai.ajax.renderer
Class MapAjaxRenderer

java.lang.Object
  extended by org.mentawai.ajax.renderer.MapAjaxRenderer
All Implemented Interfaces:
AjaxRenderer

public class MapAjaxRenderer
extends Object
implements AjaxRenderer

A AjaxRender that gets map from the action`s output and creates a XML structure with the contents of this map.

For example, a Map with this content:

 |      key      |      value      |
 |     akey      |      avalue     |
 | yetAnotherKey | yetAnotherValue |
 

Would create the folowing XML structure:
 <map>
     <entry key="akey">avalue</entry>
     <entry key="yetAnotherKey">yetAnotherValue</entry>
  </map>   
 

The tag names ("map" & "entry") may be changed.

Then you can use your favorite JavaScript parser (or use your own) to parse the generated XML strucure and interact it in your code.

Author:
Rubem Azenha (rubem.azenha@gmail.com), Fernando Boaglio - update to jdom 1.0

Field Summary
static String CHILD
           
static String FATHER
           
static String KEY
           
 
Fields inherited from interface org.mentawai.ajax.AjaxRenderer
APP_JS, APP_JSON, APP_URLENCODED, TEXT_HTML, TEXT_PLAIN, TEXT_XML
 
Constructor Summary
MapAjaxRenderer()
           
MapAjaxRenderer(String root, String child, String key)
           
 
Method Summary
 String encode(Object obj, Locale loc, boolean pretty)
           
 String getCharset()
           
 String getContentType()
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FATHER

public static final String FATHER
See Also:
Constant Field Values

CHILD

public static final String CHILD
See Also:
Constant Field Values

KEY

public static final String KEY
See Also:
Constant Field Values
Constructor Detail

MapAjaxRenderer

public MapAjaxRenderer(String root,
                       String child,
                       String key)

MapAjaxRenderer

public MapAjaxRenderer()
Method Detail

encode

public String encode(Object obj,
                     Locale loc,
                     boolean pretty)
              throws Exception
Specified by:
encode in interface AjaxRenderer
Throws:
Exception

getContentType

public String getContentType()
Specified by:
getContentType in interface AjaxRenderer

getCharset

public String getCharset()
Specified by:
getCharset in interface AjaxRenderer

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2013. All Rights Reserved.