grails.util
Class OpenRicoBuilder

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by groovy.util.BuilderSupport
          extended by groovy.xml.MarkupBuilder
              extended by grails.util.OpenRicoBuilder
All Implemented Interfaces:
groovy.lang.GroovyObject

public class OpenRicoBuilder
extends groovy.xml.MarkupBuilder

OpenRicoBuilder provides support for creating OpenRico AJAX responses.

If this builder is used in controllers no views should be configured since content will be written to the HttpServletResponse instance. Also no operations should be performed on the response object prior to passing it to this builder.

This builder will set the content type of the response to "text/xml" and will render a correct XML prolog ().

This builder supports no namespaces or hyphens in element and attribute names.

Use this builder to write a OpenRico reponse to the client. Sending a simple DIV tag to the client requires this code:

 new OpenRicoBuilder(response).ajax { element(id:"personInfo") { div(class:"person") } }
 

Sending object XML to the client requires this code:

 new OpenRicoBuilder(response).ajax { object(id:"formLetterUpdater") { 
     person(
         fullName:"Pat Barnes",
         title:"Mr.",
         firstName:"Pat",
         lastName:"Barnes")
     }
 }
 

The first call on a OpenRicoBuilder instance should be "ajax", the second either "element" (to return HTML) or object (to return XML) both with a required "id" attribute. Violations against these rules will be reported as exceptions.

OpenRico responses can contain multiple element and/or object nodes which is supported by this builder.

When using OpenRicoBuilder in controllers you may need to return a null value at the end of a closure to avoid an UnsupporterReturnValueException.

Since:
Jul 5, 2005
Author:
Steven Devijver

Constructor Summary
OpenRicoBuilder(HttpServletResponse response)
           
 
Method Summary
protected  Object createNode(Object name)
           
protected  Object createNode(Object name, Map attributes, Object value)
           
protected  Object createNode(Object name, Object value)
           
protected  void nodeCompleted(Object parent, Object node)
           
 
Methods inherited from class groovy.xml.MarkupBuilder
createNode, getDoubleQuotes, getMkp, getName, getPrinter, isOmitEmptyAttributes, isOmitNullAttributes, print, setDoubleQuotes, setOmitEmptyAttributes, setOmitNullAttributes, setParent, transformValue, yield, yieldUnescaped
 
Methods inherited from class groovy.util.BuilderSupport
doInvokeMethod, getCurrent, invokeMethod, invokeMethod, postNodeCompletion, setClosureDelegate, setCurrent
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, getProperty, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenRicoBuilder

public OpenRicoBuilder(HttpServletResponse response)
                throws IOException
Throws:
IOException
Method Detail

createNode

protected Object createNode(Object name)
Overrides:
createNode in class groovy.xml.MarkupBuilder

createNode

protected Object createNode(Object name,
                            Map attributes,
                            Object value)
Overrides:
createNode in class groovy.xml.MarkupBuilder

createNode

protected Object createNode(Object name,
                            Object value)
Overrides:
createNode in class groovy.xml.MarkupBuilder

nodeCompleted

protected void nodeCompleted(Object parent,
                             Object node)
Overrides:
nodeCompleted in class groovy.xml.MarkupBuilder


Copyright (c) 2005-2009 The Grails project