net.sf.tacos.ajax
Interface ResponseBuilder

All Known Implementing Classes:
DojoResponseBuilder, PrototypeResponseBuilder

public interface ResponseBuilder

Represents the class responsible for interacting with components for an ajax request library version and type.

Author:
jkuhenrt

Field Summary
static String SCRIPT_BLOCK
          Id of html element that dynamic javascript contributions will be made to by core tapestry components.
 
Method Summary
 void addExceptionResponse(org.apache.tapestry.IPage exceptionPage, org.apache.tapestry.IRequestCycle cycle)
          Adds the specified Exception page to Ajax response.
 void addPostProcessScript(String script)
          Script that will be executed just after any content replacements in the response, but before anything in the normal script blocks.
 void addPreProcessScript(String script)
          Adds the specified script string to the preprocessing section of the client response.
 void addResponseBlock(String id, String data)
          Adds an arbitrary block of markup to this responses response.
 void addStatusResponse(String status)
          Adds an xml response block of type "statustext".
 void cleanupAfterRender()
          Invoked by AjaxDirectService after a request cycle so invokers can cleanup resources.
 boolean componentWriterExists(String id)
          Checks for the existance of a previously created component IMarkupWriter, this is currently only used in manual block writing semantics, specifically in the Tree components rendering logic.
 AjaxWebRequest getAjaxRequest()
          The ajax request
 org.apache.tapestry.IMarkupWriter getComponentWriter(String id)
          Gets a NestedMarkupWriter for the specified component to write to and caches the buffer for later write to the stream via the cleanupAfterRender().
 String getContentType()
          Should return the content type response that this builder generates.
 org.apache.tapestry.IMarkupWriter getScriptWriter()
          Return a valid writer instance that is setup to write to the SCRIPT_BLOCK portion of the response.
 org.apache.tapestry.IMarkupWriter getWriter()
          The writer
 org.apache.tapestry.IMarkupWriter getWriter(org.apache.tapestry.IComponent component, org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IMarkupWriter writer)
          Invoked by enhanced IRender.render(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle) methods before rendering to replace their incoming IMarkupWriter instance with the one provided by this class, which may return the same writer or a special writer depending on the circumstances.
 void prepareForRender()
          Called before invoking either updateComponentsDirect(IRequestCycle, IPage, IPage, IComponent), or if in full render mode invoking renderRequest(
 void removeComponentWriter(String id)
          Removes the specified IMarkupWriter from this reponse, if it exists.
 void renderResponse(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IPage activePage, org.apache.tapestry.IPage componentPage, org.apache.tapestry.IComponent component)
          Called to render a complete response to the client, in the case of of direct component updates being set to false.
 void setAjaxRequest(AjaxWebRequest ajaxRequest)
          Sets the associated ajax request.
 void setWriter(org.apache.tapestry.IMarkupWriter writer)
          Sets the text/xml response writer.
 void updateComponentsDirect(org.apache.tapestry.IRequestCycle cycle, org.apache.tapestry.IPage activePage, org.apache.tapestry.IPage componentPage, org.apache.tapestry.IComponent component)
          Called to update all components in cycle directly, without causing any other component to render output.
 

Field Detail

SCRIPT_BLOCK

static final String SCRIPT_BLOCK
Id of html element that dynamic javascript contributions will be made to by core tapestry components.

See Also:
Constant Field Values
Method Detail

getAjaxRequest

AjaxWebRequest getAjaxRequest()
The ajax request

Returns:

setAjaxRequest

void setAjaxRequest(AjaxWebRequest ajaxRequest)
Sets the associated ajax request.

Parameters:
ajaxRequest -

getWriter

org.apache.tapestry.IMarkupWriter getWriter()
The writer

Returns:

setWriter

void setWriter(org.apache.tapestry.IMarkupWriter writer)
Sets the text/xml response writer.

Parameters:
writer -

getWriter

org.apache.tapestry.IMarkupWriter getWriter(org.apache.tapestry.IComponent component,
                                            org.apache.tapestry.IRequestCycle cycle,
                                            org.apache.tapestry.IMarkupWriter writer)
Invoked by enhanced IRender.render(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle) methods before rendering to replace their incoming IMarkupWriter instance with the one provided by this class, which may return the same writer or a special writer depending on the circumstances.

Parameters:
component -
cycle -
writer - Current writer rendering response
Returns:
A valid IMarkupWriter, which may be a NullWriter, an ajax xml response stream, or a normal html response stream.

prepareForRender

void prepareForRender()
Called before invoking either updateComponentsDirect(IRequestCycle, IPage, IPage, IComponent), or if in full render mode invoking renderRequest(


updateComponentsDirect

void updateComponentsDirect(org.apache.tapestry.IRequestCycle cycle,
                            org.apache.tapestry.IPage activePage,
                            org.apache.tapestry.IPage componentPage,
                            org.apache.tapestry.IComponent component)
Called to update all components in cycle directly, without causing any other component to render output.

Parameters:
cycle -
activePage -
componentPage -
component -

renderResponse

void renderResponse(org.apache.tapestry.IRequestCycle cycle,
                    org.apache.tapestry.IPage activePage,
                    org.apache.tapestry.IPage componentPage,
                    org.apache.tapestry.IComponent component)
Called to render a complete response to the client, in the case of of direct component updates being set to false.

Parameters:
cycle -
activePage -
componentPage -
component -

cleanupAfterRender

void cleanupAfterRender()
Invoked by AjaxDirectService after a request cycle so invokers can cleanup resources.

In the case of full page/non direct component invocations this causes all the buffered component IMarkupWriter instances to have their contents written to the response stream.


getContentType

String getContentType()
Should return the content type response that this builder generates. Ie "text/plain" or "text/xml". These content types must also exist in the hivemodule.xml contribution tapestry.markup.MarkupFilters.

Returns:
A valid content type required by this builder.

addResponseBlock

void addResponseBlock(String id,
                      String data)
Adds an arbitrary block of markup to this responses response. If the specified component/block id is already associated with a writer this data will be appended to the already existing writer, else a new block will be created.

This method is especially useful for situations where javascript should be inserted into the response for an element that may not otherwise render any content.

Parameters:
id - The component/block id to associate with response.
data - The content to write

getScriptWriter

org.apache.tapestry.IMarkupWriter getScriptWriter()
Return a valid writer instance that is setup to write to the SCRIPT_BLOCK portion of the response.

Returns:
A valid markup writer.

getComponentWriter

org.apache.tapestry.IMarkupWriter getComponentWriter(String id)
Gets a NestedMarkupWriter for the specified component to write to and caches the buffer for later write to the stream via the cleanupAfterRender().

Parameters:
id -
Returns:
Writer component will write to.

removeComponentWriter

void removeComponentWriter(String id)
Removes the specified IMarkupWriter from this reponse, if it exists.

Parameters:
id -

componentWriterExists

boolean componentWriterExists(String id)
Checks for the existance of a previously created component IMarkupWriter, this is currently only used in manual block writing semantics, specifically in the Tree components rendering logic.

Returns:

addStatusResponse

void addStatusResponse(String status)
Adds an xml response block of type "statustext".

Parameters:
status -
See Also:
AjaxWebRequest.addStatusResponse(String)

addPreProcessScript

void addPreProcessScript(String script)
Adds the specified script string to the preprocessing section of the client response.

Parameters:
script -

addPostProcessScript

void addPostProcessScript(String script)
Script that will be executed just after any content replacements in the response, but before anything in the normal script blocks.

Parameters:
script -

addExceptionResponse

void addExceptionResponse(org.apache.tapestry.IPage exceptionPage,
                          org.apache.tapestry.IRequestCycle cycle)
Adds the specified Exception page to Ajax response.

Parameters:
exceptionPage -
cycle -