|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ResponseBuilder
Represents the service responsible for managing all content output that is sent
to the client. In the case of normal http responses this management would inlude
handing out IMarkupWriter
instances to render components with, as well as
managing any javascript written to the output using Script templates.
This is a major internal change in terms of the way tapestry renders pages/components. Traditionally a response has been rendered via: IPage.render(writer, cycle); The logic has now changed somewhat, while the IPage.render(writer, cycle) does still happen, this service is the primary invoker of all renders, even nested component bodies. That means that in the majority of cases the ResponseBuilder service is used to invoke IComponent.render() throught the entire render cycle, creating a great deal of flexibility in terms of what can be done to control the output of a given response.
This service was primarily created to help bolster support for more dynamic content responses, such as XHR/JSON/etc - where controlling individual component output (and javascript) becomes very important when managaing client side browser state.
Field Summary | |
---|---|
static String |
BODY_SCRIPT
|
static String |
CONTENT_TYPE
The content type of the response that will be returned. |
static String |
ELEMENT_TYPE
The response element type. |
static String |
ENCODING_KEY
Inside a ContentType , the output encoding is called
"charset". |
static String |
EXCEPTION_TYPE
The response exception type. |
static String |
INCLUDE_SCRIPT
|
static String |
INITIALIZATION_SCRIPT
|
static String |
PAGE_TYPE
The response element type denoting a brand new page render. |
static String |
SCRIPT_TYPE
|
Method Summary | |
---|---|
void |
addStatusMessage(IMarkupWriter writer,
String category,
String text)
Adds a status message to the current response. |
void |
beginBodyScript(IMarkupWriter writer,
IRequestCycle cycle)
Marks the beginning of the core body script. |
boolean |
contains(IComponent target)
Checks if the rendered response contains a particular component. |
void |
endBodyScript(IMarkupWriter writer,
IRequestCycle cycle)
Marks the end of the body block being called. |
boolean |
explicitlyContains(IComponent target)
Similar to contains(IComponent) , but only returns true if the component
has been marked for update directly via an updateComponents property
or by calling updateComponent(String) directly. |
void |
flush()
Causes the output stream to be flushed, used primarily in concert with IRequestCycle to sync
up flushing of headers to the browser once any page changes have been committed. |
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(String id,
String type)
Gets a write that will output its content in a response
element with the given id and type. |
boolean |
isDynamic()
Implementors that manage content writes dynamically (ie DojoAjaxResponseBuilder ) should
return true to denote that dynamic behaviour is on for a particular response. |
boolean |
isImageInitializationAllowed(IComponent target)
Determines if the specified component should have any asset image URL references embedded in 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(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(IMarkupWriter writer,
IRequestCycle cycle)
Invoked by components that know "when" the method should be called. |
void |
writeBodyScript(IMarkupWriter writer,
String script,
IRequestCycle cycle)
Called after beginBodyScript(IMarkupWriter, IRequestCycle) to write the containing
body script. |
void |
writeExternalScript(IMarkupWriter writer,
String url,
IRequestCycle cycle)
Invoked by PageRenderSupport to write external js package
includes. |
void |
writeImageInitializations(IMarkupWriter writer,
String script,
String preloadName,
IRequestCycle cycle)
Intended to be written within the confines of the body script, should be invoked once just after beginBodyScript(IMarkupWriter, IRequestCycle) is called
to include any image initializations. |
void |
writeInitializationScript(IMarkupWriter writer)
Invoked by components that know "when" the method should be called. |
void |
writeInitializationScript(IMarkupWriter writer,
String script)
Writes any javascript that should only execute after all other items on a page have completed rendering. |
Methods inherited from interface org.apache.tapestry.PageRenderSupport |
---|
getPreloadedImageReference, getPreloadedImageReference, getPreloadedImageReference |
Methods inherited from interface org.apache.tapestry.IScriptProcessor |
---|
addBodyScript, addBodyScript, addExternalScript, addExternalScript, addInitializationScript, addInitializationScript, addScriptAfterInitialization, getUniqueString, isBodyScriptAllowed, isExternalScriptAllowed, isInitializationScriptAllowed |
Field Detail |
---|
static final String ENCODING_KEY
ContentType
, the output encoding is called
"charset".
static final String CONTENT_TYPE
static final String ELEMENT_TYPE
static final String EXCEPTION_TYPE
static final String PAGE_TYPE
static final String SCRIPT_TYPE
static final String BODY_SCRIPT
static final String INCLUDE_SCRIPT
static final String INITIALIZATION_SCRIPT
Method Detail |
---|
boolean isDynamic()
DojoAjaxResponseBuilder
) should
return true to denote that dynamic behaviour is on for a particular response.
void flush() throws IOException
IRequestCycle
to sync
up flushing of headers to the browser once any page changes have been committed.
IOException
- During io error.void renderResponse(IRequestCycle cycle) throws IOException
cycle
- The main request cycle object for this request.
IOException
- During io error.void render(IMarkupWriter writer, IRender render, IRequestCycle cycle)
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 rendercycle
- Render request cyclevoid updateComponent(String id)
id
- The IComponent
id to update.boolean contains(IComponent target)
target
- The component to check containment of.
boolean explicitlyContains(IComponent target)
contains(IComponent)
, but only returns true if the component
has been marked for update directly via an updateComponents
property
or by calling updateComponent(String)
directly.
IMPORTANT!: This will not return true for components contained by a component
marked for update. If you want that kind of behaviour use contains(IComponent)
.
target
- The component to check.
void writeBodyScript(IMarkupWriter writer, IRequestCycle cycle)
writer
- The writer to use . (may / may not be ignored depending on the response type)cycle
- Associated request.void writeInitializationScript(IMarkupWriter writer)
writer
- The writer to use . (may / may not be ignored depending on the response type)void writeExternalScript(IMarkupWriter writer, String url, IRequestCycle cycle)
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
.
writer
- The markup writer to use, this may be ignored or swapped
out for a different writer depending on the implementation being used.url
- The absolute url to the .js package to be included.cycle
- The associated request.void beginBodyScript(IMarkupWriter writer, IRequestCycle cycle)
writer
- The markup writer to use, this may be ignored or swapped
out for a different writer depending on the implementation being used.cycle
- The associated request.void writeImageInitializations(IMarkupWriter writer, String script, String preloadName, IRequestCycle cycle)
beginBodyScript(IMarkupWriter, 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.
writer
- The markup writer to use, this may be ignored or swapped
out for a different writer depending on the implementation being used.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.void writeBodyScript(IMarkupWriter writer, String script, IRequestCycle cycle)
beginBodyScript(IMarkupWriter, 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.
writer
- The markup writer to use, this may be ignored or swapped
out for a different writer depending on the implementation being used.script
- The script to write into the body response.cycle
- The associated request.void endBodyScript(IMarkupWriter writer, IRequestCycle cycle)
beginBodyScript(IMarkupWriter, IRequestCycle)
was previously
called.
writer
- The markup writer to use, this may be ignored or swapped
out for a different writer depending on the implementation being used.cycle
- The associated request.void writeInitializationScript(IMarkupWriter writer, String script)
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.
writer
- The markup writer to use, this may be ignored or swapped
out for a different writer depending on the implementation being used.script
- The initialzation script to write.IMarkupWriter getWriter()
IMarkupWriter getWriter(String id, String type)
response
element with the given id and type.
id
- The response element id to give writer.type
- Optional - If specified will give the response element a type
attribute.
IMarkupWriter
instance to write content to.boolean isImageInitializationAllowed(IComponent target)
target
- The component to allow/disallow image initialization script content from.
void addStatusMessage(IMarkupWriter writer, String category, String text)
writer
- The markup writer to use, this may be ignored or swapped
out for a different writer depending on the implementation being used.category
- Allows setting a category that best describes the type of the status message,
i.e. info, error, e.t.c.text
- The status message.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |