org.apache.tapestry.services
Interface ResponseBuilder

All Known Implementing Classes:
DefaultResponseBuilder, DojoAjaxResponseBuilder, JSONResponseBuilder

public interface ResponseBuilder

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

Since:
4.1
Author:
jkuhnert

Field Summary
static java.lang.String BODY_SCRIPT
           
static java.lang.String INCLUDE_SCRIPT
           
static java.lang.String INITIALIZATION_SCRIPT
           
static java.lang.String SCRIPT_TYPE
           
 
Method Summary
 void beginBodyScript(IRequestCycle cycle)
          Marks the beginning of the core body script.
 void endBodyScript(IRequestCycle cycle)
          Marks the end of the body block being called.
 IMarkupWriter getWriter()
          Returns the IMarkupWriter associated with this response, it may or may not be a NullWriter instance depending on the response type or stage of the render cycle.
 IMarkupWriter getWriter(java.lang.String id, java.lang.String type)
          Gets a write that will output its content in a response element with the given id and type.
 boolean isBodyScriptAllowed(IComponent target)
          Determines if the specified component should have its javascript body added to the response.
 boolean isExternalScriptAllowed(IComponent target)
          Determines if the specified component should have its javascript external resource scripts added to the response.
 boolean isInitializationScriptAllowed(IComponent target)
          Determines if the specified component should have its javascript initialization added to the response.
 void render(IMarkupWriter writer, IRender render, IRequestCycle cycle)
          Invoked to render a renderable object.
 void renderResponse(IRequestCycle cycle)
          Renders the response to a client.
 void updateComponent(java.lang.String id)
          If the component identified by the specified id isn't already set to be updated, will add it to the response for updating.
 void writeBodyScript(java.lang.String script, IRequestCycle cycle)
          Called after beginBodyScript(IRequestCycle) to write the containing body script.
 void writeExternalScript(java.lang.String url, IRequestCycle cycle)
          Invoked by PageRenderSupport to write external js package includes.
 void writeImageInitializations(java.lang.String script, java.lang.String preloadName, IRequestCycle cycle)
          Intended to be written within the confines of the body script, should be invoked once just after beginBodyScript(IRequestCycle) is called to include any image initializations.
 void writeInitializationScript(java.lang.String script)
          Writes any javascript that should only execute after all other items on a page have completed rendering.
 

Field Detail

SCRIPT_TYPE

static final java.lang.String SCRIPT_TYPE
See Also:
Constant Field Values

BODY_SCRIPT

static final java.lang.String BODY_SCRIPT
See Also:
Constant Field Values

INCLUDE_SCRIPT

static final java.lang.String INCLUDE_SCRIPT
See Also:
Constant Field Values

INITIALIZATION_SCRIPT

static final java.lang.String INITIALIZATION_SCRIPT
See Also:
Constant Field Values
Method Detail

renderResponse

void renderResponse(IRequestCycle cycle)
                    throws java.io.IOException
Renders the response to a client. Handles transitioning logic for setting up page and associated components for response.

Parameters:
cycle - The main request cycle object for this request.
Throws:
java.io.IOException

render

void render(IMarkupWriter writer,
            IRender render,
            IRequestCycle cycle)
Invoked to render a renderable object. Performs any necessary under the hood type logic involving ajax/json/normal responses, where needed.

Parameters:
writer - The markup writer to use, this may be ignored or swapped out for a different writer depending on the implementation being used.
render - The renderable object to render
cycle - Render request cycle

updateComponent

void updateComponent(java.lang.String id)
If the component identified by the specified id isn't already set to be updated, will add it to the response for updating. (Only applicable in dynamic responses such as XHR/JSON ).

Parameters:
id - The IComponent id to update.

writeExternalScript

void writeExternalScript(java.lang.String url,
                         IRequestCycle cycle)
Invoked by PageRenderSupport to write external js package includes. This method will be invoked for each external script requesting inclusion in the response. These will typically be written out as .

Parameters:
url - The absolute url to the .js package to be included.
cycle - The associated request.

beginBodyScript

void beginBodyScript(IRequestCycle cycle)
Marks the beginning of the core body script.

Parameters:
cycle - The associated request.

writeImageInitializations

void writeImageInitializations(java.lang.String script,
                               java.lang.String preloadName,
                               IRequestCycle cycle)
Intended to be written within the confines of the body script, should be invoked once just after beginBodyScript(IRequestCycle) is called to include any image initializations. This method should only be called if there are actually images that need pre-initialization. Ie in many instances it will not be called at all.

Parameters:
script - The non null value of the script images to include.
preloadName - The global variable name to give to the preloaded images array.
cycle - The associated request.

writeBodyScript

void writeBodyScript(java.lang.String script,
                     IRequestCycle cycle)
Called after beginBodyScript(IRequestCycle) to write the containing body script. This method may not be called at all if there is no js body to write into the response.

Parameters:
script - The script to write into the body response.
cycle - The associated request.

endBodyScript

void endBodyScript(IRequestCycle cycle)
Marks the end of the body block being called. This method will always be called if beginBodyScript(IRequestCycle) was previously called.

Parameters:
cycle - The associated request.

writeInitializationScript

void writeInitializationScript(java.lang.String script)
Writes any javascript that should only execute after all other items on a page have completed rendering. This is typically implemented via wrapping the executing of the code to some sort of window.onload event, but will vary depending on the implementation of the builder being used. This method will ~only~ be called if there is any queued intialization script to write.

Parameters:
script - The initialzation script to write.

getWriter

IMarkupWriter getWriter()
Returns the IMarkupWriter associated with this response, it may or may not be a NullWriter instance depending on the response type or stage of the render cycle. (specifically during rewind)

Returns:
A validly writable markup writer, even if the content is sometimes ignored.

getWriter

IMarkupWriter getWriter(java.lang.String id,
                        java.lang.String type)
Gets a write that will output its content in a response element with the given id and type.

Parameters:
id - The response element id to give writer.
type - Optional - If specified will give the response element a type attribute.
Returns:
A valid IMarkupWriter instance to write content to.

isBodyScriptAllowed

boolean isBodyScriptAllowed(IComponent target)
Determines if the specified component should have its javascript body added to the response.

Parameters:
target - The component to allow/disallow body script content from.
Returns:
True if the component script should be allowed.

isInitializationScriptAllowed

boolean isInitializationScriptAllowed(IComponent target)
Determines if the specified component should have its javascript initialization added to the response.

Parameters:
target - The component to allow/disallow initialization script content from.
Returns:
True if the component script should be allowed.

isExternalScriptAllowed

boolean isExternalScriptAllowed(IComponent target)
Determines if the specified component should have its javascript external resource scripts added to the response.

Parameters:
target - The component to check for inclusion/exclusion.
Returns:
True if external scripts from this component should be added to the response.


Copyright © 2006 Apache Software Foundation. All Rights Reserved.