|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.lang.GroovyObjectSupport groovy.util.BuilderSupport groovy.xml.MarkupBuilder grails.util.OpenRicoBuilder
public class OpenRicoBuilder
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.
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 |
---|
public OpenRicoBuilder(HttpServletResponse response) throws IOException
IOException
Method Detail |
---|
protected Object createNode(Object name)
createNode
in class groovy.xml.MarkupBuilder
protected Object createNode(Object name, Map attributes, Object value)
createNode
in class groovy.xml.MarkupBuilder
protected Object createNode(Object name, Object value)
createNode
in class groovy.xml.MarkupBuilder
protected void nodeCompleted(Object parent, Object node)
nodeCompleted
in class groovy.xml.MarkupBuilder
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |