public class ERXResponseRewriter extends Object
Name | Description |
---|---|
er.extensions.loadOnDemand | if true , javascript files included in Ajax responses will be loaded on-demand (defaults to true ) |
er.ajax.secureResources | if true , load all resources with https (default false) |
er.ajax.AJComponent.htmlCloseHead | the tag to insert in front of (defaults to </head>) |
er.extensions.ERXResponseRewriter.javascriptTypeAttribute | if true , type="text/javascript"
will be added to injected script tags (defaults false ). For valid HTML you have to set this to
true for HTML4 and XHTML but HTML5 will default to text/javascript if that attribute
is missing. |
Modifier and Type | Class and Description |
---|---|
static class |
ERXResponseRewriter.ContextObserver
ERXResponseRewriter uses the ContextObserver to reset the topIndex value at the end
of the request.
|
static interface |
ERXResponseRewriter.Delegate
The delegate that is called prior to adding resources into the page,
which gives you a chance to deny the addition, or rewrite the addition to
a custom resource.
|
static class |
ERXResponseRewriter.Resource
Represents a resource in a framework, or a fully-qualified URL if
fileName starts with a / or contains :// .
|
static class |
ERXResponseRewriter.TagMissingBehavior
TagMissingBehavior specifies several ways the response rewriter should
handle the case of having a missing tag that you attempted to insert in
front of (for instance, if you ask to insert in the head tag and the head
tag does not exist).
|
Constructor and Description |
---|
ERXResponseRewriter() |
Modifier and Type | Method and Description |
---|---|
static String |
_htmlCloseHeadTag()
Returns the tag name that scripts and resources should be inserted above.
|
static void |
addResourceInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String framework,
String fileName,
String startTag,
String endTag)
Adds a reference to an arbitrary file with a correct resource URL wrapped
between startTag and endTag in the HTML head tag if it isn't already
present in the response.
|
static boolean |
addResourceInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String framework,
String fileName,
String startTag,
String endTag,
ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
Adds a reference to an arbitrary file with a correct resource URL wrapped
between startTag and endTag in the HTML head tag if it isn't already
present in the response.
|
static boolean |
addResourceInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String framework,
String fileName,
String startTag,
String endTag,
String fallbackStartTag,
String fallbackEndTag,
ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
Adds a reference to an arbitrary file with a correct resource URL wrapped
between startTag and endTag in the HTML head tag if it isn't already
present in the response.
|
static void |
addScriptCodeInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String script)
Adds javascript code in a script tag in the HTML head tag (without a
name).
|
static void |
addScriptCodeInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String script,
String scriptName)
Adds javascript code in a script tag in the HTML head tag or inline if
the request is an Ajax request.
|
static void |
addScriptResourceInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String framework,
String fileName)
Adds a script tag with a correct resource URL into the HTML head tag if
it isn't already present in the response, or inserts an Ajax OnDemand tag
if the current request is an Ajax request.
|
static void |
addStylesheetResourceInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String framework,
String fileName)
Adds a stylesheet link tag with a correct resource URL in the HTML head
tag if it isn't already present in the response.
|
static void |
addStylesheetResourceInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String framework,
String fileName,
String media)
Adds a stylesheet link tag with a correct resource URL in the HTML head
tag if it isn't already present in the response.
|
static NSMutableDictionary<String,Object> |
ajaxPageUserInfo(com.webobjects.appserver.WOContext context)
Returns the page userInfo for the page component of the given context.
|
static void |
appendScriptTagCloser(com.webobjects.appserver.WOResponse response)
Appends the closing script tag to the given response.
|
static void |
appendScriptTagOpener(com.webobjects.appserver.WOResponse response)
Appends a script tag with or without type attribute depending on the
corresponding property value.
|
static boolean |
insertInResponseBeforeHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String content,
ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
Utility to add the given content into the response before the close of
the head tag.
|
static boolean |
insertInResponseBeforeTag(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String content,
String tag,
ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
Utility to add the given content into the response before a particular
HTML tag.
|
static boolean |
isResourceAddedToHead(com.webobjects.appserver.WOContext context,
String frameworkName,
String resourceName)
Returns whether or not the given resource has been added to the HEAD tag.
|
static NSMutableDictionary<String,Object> |
pageUserInfo(com.webobjects.appserver.WOComponent page)
Returns the page userInfo for the given page component.
|
static NSMutableDictionary<String,Object> |
pageUserInfo(com.webobjects.appserver.WOContext context)
Returns the page userInfo for the page component of the given context.
|
static void |
replaceAllInResponse(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
Pattern pattern,
String replacement)
Replaces all occurrences of the given pattern in the response with the replacement string.
|
static void |
replaceFirstInResponse(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
Pattern pattern,
String replacement)
Replaces the first occurrence of the given pattern in the response with the replacement string.
|
static void |
resourceAddedToHead(com.webobjects.appserver.WOContext context,
String frameworkName,
String resourceName)
Records that the given resource (within the given framework) has been
added to the head of this page.
|
static NSMutableSet<String> |
resourcesAddedToHead(com.webobjects.appserver.WOContext context)
Returns the resources that have been added to the head of this page.
|
static void |
setDelegate(ERXResponseRewriter.Delegate delegate)
Sets the response rewriter delegate to be used by this Application.
|
public static void setDelegate(ERXResponseRewriter.Delegate delegate)
delegate
- the response rewriter delegate to be used by this Application,
or null
to use the defaultpublic static NSMutableDictionary<String,Object> ajaxPageUserInfo(com.webobjects.appserver.WOContext context)
context
- the context to lookuppublic static NSMutableDictionary<String,Object> pageUserInfo(com.webobjects.appserver.WOContext context)
context
- the context to lookuppublic static NSMutableDictionary<String,Object> pageUserInfo(com.webobjects.appserver.WOComponent page)
page
- the component to lookuppublic static String _htmlCloseHeadTag()
public static boolean insertInResponseBeforeHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String content, ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
response
- the WOResponsecontext
- the WOContextcontent
- the content to insert.tagMissingBehavior
- how to handle the case where the tag is missingpublic static void replaceAllInResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, Pattern pattern, String replacement)
response
- the responsecontext
- the contextpattern
- the pattern to matchreplacement
- the replacement valuepublic static void replaceFirstInResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, Pattern pattern, String replacement)
response
- the responsecontext
- the contextpattern
- the pattern to matchreplacement
- the replacement valuepublic static boolean insertInResponseBeforeTag(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String content, String tag, ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
response
- the responsecontext
- the contextcontent
- the content to inserttag
- the tag to insert before (in HTML syntax)tagMissingBehavior
- how to handle the case where the tag is missingpublic static void addScriptResourceInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String framework, String fileName)
response
- the responsecontext
- the contextframework
- the framework that contains the filefileName
- the name of the javascript file to addpublic static void addStylesheetResourceInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String framework, String fileName)
context
- the contextresponse
- the responseframework
- the framework that contains the filefileName
- the name of the CSS file to addpublic static void addStylesheetResourceInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String framework, String fileName, String media)
context
- the contextresponse
- the responseframework
- the framework that contains the filefileName
- the name of the CSS file to addmedia
- the media type of the stylesheet (or null
for default)public static void addScriptCodeInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String script)
response
- the response to write intocontext
- the contextscript
- the javascript code to insertpublic static void addScriptCodeInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String script, String scriptName)
response
- the response to write intocontext
- the contextscript
- the javascript code to insertscriptName
- the name of the script to insert (for duplicate checking)public static void addResourceInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String framework, String fileName, String startTag, String endTag)
response
- the responsecontext
- the contextframework
- the framework that contains the filefileName
- the name of the file to addstartTag
- the HTML to prepend before the URLendTag
- the HTML to append after the URLpublic static NSMutableSet<String> resourcesAddedToHead(com.webobjects.appserver.WOContext context)
context
- the contextpublic static boolean isResourceAddedToHead(com.webobjects.appserver.WOContext context, String frameworkName, String resourceName)
context
- the contextframeworkName
- the framework name of the resourceresourceName
- the name of the resource to checktrue
if the resource has been added to headpublic static void resourceAddedToHead(com.webobjects.appserver.WOContext context, String frameworkName, String resourceName)
context
- the contextframeworkName
- the framework name of the resourceresourceName
- the name of the resourcepublic static boolean addResourceInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String framework, String fileName, String startTag, String endTag, ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
response
- the responsecontext
- the contextframework
- the framework that contains the filefileName
- the name of the file to addstartTag
- the HTML to prepend before the URLendTag
- the HTML to append after the URLtagMissingBehavior
- how to handle the case where the tag is missingpublic static boolean addResourceInHead(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, String framework, String fileName, String startTag, String endTag, String fallbackStartTag, String fallbackEndTag, ERXResponseRewriter.TagMissingBehavior tagMissingBehavior)
response
- the responsecontext
- the contextframework
- the framework that contains the filefileName
- the name of the file to addstartTag
- the HTML to prepend before the URLendTag
- the HTML to append after the URLfallbackStartTag
- fallbackEndTag
- tagMissingBehavior
- how to handle the case where the tag is missingpublic static void appendScriptTagOpener(com.webobjects.appserver.WOResponse response)
response
- response object to add opening script tag topublic static void appendScriptTagCloser(com.webobjects.appserver.WOResponse response)
response
- response object to add closing script tag toCopyright © 2002 – 2020 Project Wonder.