|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tapestry.services.impl.DojoAjaxResponseBuilder
public class DojoAjaxResponseBuilder
Main class that handles dojo based ajax responses. These responses are wrapped by an xml document format that segments off invididual component/javascript response types into easy to manage xml elements that can then be interpreted and managed by running client-side javascript.
Field Summary |
---|
Fields inherited from interface org.apache.tapestry.services.ResponseBuilder |
---|
BODY_SCRIPT, CONTENT_TYPE, ELEMENT_TYPE, ENCODING_KEY, EXCEPTION_TYPE, INCLUDE_SCRIPT, INITIALIZATION_SCRIPT, PAGE_TYPE, SCRIPT_TYPE |
Constructor Summary | |
---|---|
DojoAjaxResponseBuilder(IRequestCycle cycle,
IMarkupWriter writer,
List parts)
Creates a builder with a pre-configured IMarkupWriter . |
|
DojoAjaxResponseBuilder(IRequestCycle cycle,
IMarkupWriter writer,
List parts,
List errorPages)
Creates a builder with a pre-configured IMarkupWriter . |
|
DojoAjaxResponseBuilder(IRequestCycle cycle,
RequestLocaleManager localeManager,
MarkupWriterSource markupWriterSource,
WebResponse webResponse,
List errorPages,
AssetFactory assetFactory,
String namespace,
IEngineService pageService)
Creates a new response builder with the required services it needs to render the response when renderResponse(IRequestCycle) is called. |
Method Summary | |
---|---|
void |
addBodyScript(IComponent target,
String script)
Adds scripting code to the main body. |
void |
addBodyScript(String script)
Adds scripting code to the main body. |
void |
addExternalScript(IComponent target,
org.apache.hivemind.Resource resource)
Adds an external script. |
void |
addExternalScript(org.apache.hivemind.Resource resource)
Adds an external script. |
void |
addInitializationScript(IComponent target,
String script)
Adds initialization script. |
void |
addInitializationScript(String script)
Adds initialization script. |
void |
addScriptAfterInitialization(IComponent target,
String script)
Works in the same way as IScriptProcessor.addInitializationScript(IComponent, String) - except this
method causes the script being added to appear after all of the script content written out
from the normal initialization script processing happens. |
void |
addStatus(IMarkupWriter normalWriter,
String text)
|
void |
addStatusMessage(IMarkupWriter normalWriter,
String category,
String text)
Adds a status message to the current response. |
void |
beginBodyScript(IMarkupWriter normalWriter,
IRequestCycle cycle)
Marks the beginning of the core body script. |
boolean |
contains(IComponent target)
Determines if the specified component is contained in the responses requested update parts. |
void |
endBodyScript(IMarkupWriter normalWriter,
IRequestCycle cycle)
Marks the end of the body block being called. |
boolean |
explicitlyContains(IComponent target)
Similar to ResponseBuilder.contains(IComponent) , but only returns true if the component
has been marked for update directly via an updateComponents property
or by calling ResponseBuilder.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. |
String |
getPreloadedImageReference(IComponent target,
IAsset source)
Operates in the same way that PageRenderSupport.getPreloadedImageReference(IComponent, String) does, except
the source is the actual IAsset of an image to preload. |
String |
getPreloadedImageReference(IComponent target,
String url)
Sets up the given URL to preload, and returns a reference to the loaded image, in the form of a snippet of JavaScript expression that can be inserted into some larger block of JavaScript as a function parameter, or as a property assignment. |
String |
getPreloadedImageReference(String url)
Sets up the given URL to preload, and returns a reference to the loaded image, in the form of a snippet of JavaScript expression that can be inserted into some larger block of JavaScript as a function parameter, or as a property assignment. |
String |
getUniqueString(String baseValue)
Ensures that the given string is unique. |
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 |
isBodyScriptAllowed(IComponent target)
Determines if the specified component should have its javascript body added to the response. |
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 |
isExternalScriptAllowed(IComponent target)
Determines if the specified component should have its javascript external resource scripts added to the response. |
boolean |
isImageInitializationAllowed(IComponent target)
Determines if the specified component should have any asset image URL references embedded in 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(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 normalWriter,
String script,
IRequestCycle cycle)
Called after ResponseBuilder.beginBodyScript(IMarkupWriter, IRequestCycle) to write the containing
body script. |
void |
writeExternalScript(IMarkupWriter normalWriter,
String url,
IRequestCycle cycle)
Invoked by PageRenderSupport to write external js package
includes. |
void |
writeImageInitializations(IMarkupWriter normalWriter,
String script,
String preloadName,
IRequestCycle cycle)
Intended to be written within the confines of the body script, should be invoked once just after ResponseBuilder.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 normalWriter,
String script)
Writes any javascript that should only execute after all other items on a page have completed rendering. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DojoAjaxResponseBuilder(IRequestCycle cycle, IMarkupWriter writer, List parts, List errorPages)
IMarkupWriter
.
Currently only used for testing.
cycle
- The current cycle.writer
- The markup writer to render all "good" content to.parts
- A set of string ids of the components that may have
their responses rendered.errorPages
- List of page names known to be exception pages.public DojoAjaxResponseBuilder(IRequestCycle cycle, IMarkupWriter writer, List parts)
IMarkupWriter
.
Currently only used for testing.
cycle
- Current request.writer
- The markup writer to render all "good" content to.parts
- A set of string ids of the components that may have
their responses rendered.public DojoAjaxResponseBuilder(IRequestCycle cycle, RequestLocaleManager localeManager, MarkupWriterSource markupWriterSource, WebResponse webResponse, List errorPages, AssetFactory assetFactory, String namespace, IEngineService pageService)
renderResponse(IRequestCycle)
is called.
cycle
- The current request.localeManager
- Used to set the locale on the response.markupWriterSource
- Creates IJSONWriter instance to be used.webResponse
- Web response for output stream.errorPages
- List of page names known to be exception pages.assetFactory
- Used to manage asset source inclusions.namespace
- The core namespace to use for javascript/client side operations.pageService
- PageService
used to generate page urls.Method Detail |
---|
public boolean isDynamic()
DojoAjaxResponseBuilder
) should
return true to denote that dynamic behaviour is on for a particular response.
isDynamic
in interface ResponseBuilder
public void renderResponse(IRequestCycle cycle) throws IOException
renderResponse
in interface ResponseBuilder
cycle
- The main request cycle object for this request.
IOException
- During io error.public void flush() throws IOException
ResponseBuilder
IRequestCycle
to sync
up flushing of headers to the browser once any page changes have been committed.
flush
in interface ResponseBuilder
IOException
- During io error.public void updateComponent(String id)
updateComponent
in interface ResponseBuilder
id
- The IComponent
id to update.public IMarkupWriter getWriter()
getWriter
in interface ResponseBuilder
public boolean isBodyScriptAllowed(IComponent target)
isBodyScriptAllowed
in interface IScriptProcessor
target
- The component to allow/disallow body script content from.
public boolean isExternalScriptAllowed(IComponent target)
isExternalScriptAllowed
in interface IScriptProcessor
target
- The component to check for inclusion/exclusion.
public boolean isInitializationScriptAllowed(IComponent target)
isInitializationScriptAllowed
in interface IScriptProcessor
target
- The component to allow/disallow initialization script content from.
public boolean isImageInitializationAllowed(IComponent target)
isImageInitializationAllowed
in interface ResponseBuilder
target
- The component to allow/disallow image initialization script content from.
public String getPreloadedImageReference(IComponent target, IAsset source)
PageRenderSupport.getPreloadedImageReference(IComponent, String)
does, except
the source is the actual IAsset
of an image to preload.
getPreloadedImageReference
in interface PageRenderSupport
target
- The component the asset is being loaded for.source
- The asset image to preload.
public String getPreloadedImageReference(IComponent target, String url)
tapestry_preload[7].src
.
getPreloadedImageReference
in interface PageRenderSupport
target
- The component url being loaded for.url
- The asset URL to preload.
public String getPreloadedImageReference(String url)
tapestry_preload[7].src
.
getPreloadedImageReference
in interface PageRenderSupport
url
- The url to the resource to be preloaded.
public void addBodyScript(IComponent target, String script)
Body
component will write the body script contents
just inside the <body>
tag.
addBodyScript
in interface IScriptProcessor
target
- The component this script is being added for.script
- The script to add to the body response.public void addBodyScript(String script)
Body
component will write the body script contents
just inside the <body>
tag.
addBodyScript
in interface IScriptProcessor
#addBodyScript(IComponent, String)}
public void addExternalScript(IComponent target, org.apache.hivemind.Resource resource)
addExternalScript
in interface IScriptProcessor
target
- The component the script is being added for.resource
- The external script to add.public void addExternalScript(org.apache.hivemind.Resource resource)
addExternalScript
in interface IScriptProcessor
#addExternalScript(IComponent, Resource)}
public void addInitializationScript(IComponent target, String script)
</body>
tag).
addInitializationScript
in interface IScriptProcessor
target
- The component the script is being added for.script
- The script to add.public void addInitializationScript(String script)
</body>
tag).
addInitializationScript
in interface IScriptProcessor
#addInitializationScript(IComponent, String)}
public void addScriptAfterInitialization(IComponent target, String script)
IScriptProcessor
IScriptProcessor.addInitializationScript(IComponent, String)
- except this
method causes the script being added to appear after all of the script content written out
from the normal initialization script processing happens. This is useful if you have some initialization
script logic that absolutely must happen at the very end of the rest of things.
addScriptAfterInitialization
in interface IScriptProcessor
target
- The component the script is being added for.script
- The script to add.#addInitializationScript(IComponent, String)}.
public String getUniqueString(String baseValue)
getUniqueString
in interface IScriptProcessor
public void writeBodyScript(IMarkupWriter writer, IRequestCycle cycle)
writeBodyScript
in interface ResponseBuilder
writer
- The writer to use . (may / may not be ignored depending on the response type)cycle
- Associated request.public void writeInitializationScript(IMarkupWriter writer)
writeInitializationScript
in interface ResponseBuilder
writer
- The writer to use . (may / may not be ignored depending on the response type)public void beginBodyScript(IMarkupWriter normalWriter, IRequestCycle cycle)
beginBodyScript
in interface ResponseBuilder
normalWriter
- 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.public void endBodyScript(IMarkupWriter normalWriter, IRequestCycle cycle)
ResponseBuilder.beginBodyScript(IMarkupWriter, IRequestCycle)
was previously
called.
endBodyScript
in interface ResponseBuilder
normalWriter
- 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.public void writeBodyScript(IMarkupWriter normalWriter, String script, IRequestCycle cycle)
ResponseBuilder.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.
writeBodyScript
in interface ResponseBuilder
normalWriter
- 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.public void writeExternalScript(IMarkupWriter normalWriter, 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
.
writeExternalScript
in interface ResponseBuilder
normalWriter
- 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.public void writeImageInitializations(IMarkupWriter normalWriter, String script, String preloadName, IRequestCycle cycle)
ResponseBuilder.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.
writeImageInitializations
in interface ResponseBuilder
normalWriter
- 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.public void writeInitializationScript(IMarkupWriter normalWriter, 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.
writeInitializationScript
in interface ResponseBuilder
normalWriter
- 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.public void addStatus(IMarkupWriter normalWriter, String text)
public void addStatusMessage(IMarkupWriter normalWriter, String category, String text)
dojo.event.topic.publish(category,text);
.
addStatusMessage
in interface ResponseBuilder
normalWriter
- 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.public void render(IMarkupWriter writer, IRender render, IRequestCycle cycle)
render
in interface ResponseBuilder
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 cyclepublic IMarkupWriter getWriter(String id, String type)
response
element with the given id and type.
getWriter
in interface ResponseBuilder
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.public boolean contains(IComponent target)
contains
in interface ResponseBuilder
target
- The component to check for.
public boolean explicitlyContains(IComponent target)
ResponseBuilder.contains(IComponent)
, but only returns true if the component
has been marked for update directly via an updateComponents
property
or by calling ResponseBuilder.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 ResponseBuilder.contains(IComponent)
.
explicitlyContains
in interface ResponseBuilder
target
- The component to check.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |