public class AjaxUtils extends Object
Name | Description |
---|---|
er.ajax.compressed | er.ajax.compressed |
er.extensions.ERXResponseRewriter.javascriptTypeAttribute | er.extensions.ERXResponseRewriter.javascriptTypeAttribute |
Constructor and Description |
---|
AjaxUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addScriptCodeInHead(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
String script)
|
static void |
addScriptResourceInHead(com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOResponse response,
String fileName)
Calls
addScriptResourceInHead(WOContext, WOResponse, String, String) with "Ajax" as framework. |
static void |
addScriptResourceInHead(com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOResponse response,
String framework,
String fileName)
Adds a script 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.WOContext context,
com.webobjects.appserver.WOResponse response,
String fileName)
Calls
addStylesheetResourceInHead(WOContext, WOResponse, String, String) with "Ajax" as framework. |
static void |
addStylesheetResourceInHead(com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOResponse response,
String framework,
String fileName)
|
static String |
ajaxComponentActionUrl(com.webobjects.appserver.WOContext context)
Returns an Ajax component action url.
|
static void |
appendScript(com.webobjects.appserver.WOContext context,
String script)
Shortcut for appendScript.
|
static void |
appendScript(com.webobjects.appserver.WORequest request,
com.webobjects.appserver.WOResponse response,
String script)
Appends the given javascript to the response, surrounding it in a script header/footer if necessary.
|
static void |
appendScriptFooter(com.webobjects.appserver.WOResponse response) |
static void |
appendScriptFooterIfNecessary(com.webobjects.appserver.WORequest request,
com.webobjects.appserver.WOResponse response) |
static void |
appendScriptHeader(com.webobjects.appserver.WOResponse response) |
static void |
appendScriptHeaderIfNecessary(com.webobjects.appserver.WORequest request,
com.webobjects.appserver.WOResponse response) |
static void |
appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOComponent component,
NSDictionary<String,com.webobjects.appserver.WOAssociation> associations,
String name) |
static void |
appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOComponent component,
NSDictionary<String,com.webobjects.appserver.WOAssociation> associations,
String name,
String appendValue) |
static void |
appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOComponent component,
String name,
com.webobjects.appserver.WOAssociation association) |
static void |
appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOComponent component,
String name,
com.webobjects.appserver.WOAssociation association,
String appendValue) |
static <T> NSArray<T> |
arrayValueForAssociation(com.webobjects.appserver.WOComponent component,
com.webobjects.appserver.WOAssociation association)
Returns the array bound to the given association.
|
static <T> NSArray<T> |
arrayValueForBinding(com.webobjects.appserver.WOComponent component,
String bindingName)
Returns the array bound to the given binding name.
|
static <T> NSArray<T> |
arrayValueForObject(Object value)
Returns the array for the given object.
|
static AjaxResponse |
createResponse(com.webobjects.appserver.WORequest request,
com.webobjects.appserver.WOContext context)
Creates a response for the given context (which can be null), sets the charset to UTF-8, the connection to
keep-alive and flags it as a Ajax request by adding an AJAX_REQUEST_KEY header.
|
static boolean |
isAjaxRequest(com.webobjects.appserver.WORequest request)
Return whether or not the given request is an Ajax request.
|
static com.webobjects.appserver.WOResponse |
javascriptResponse(String javascript,
com.webobjects.appserver.WOContext context)
Returns an
AjaxResponse with the given javascript as the body of the response. |
static String |
quote(String value)
If the value is null, this returns "null", otherwise it returns '[value]'.
|
static void |
redirectTo(com.webobjects.appserver.WOComponent component)
Creates (or modifies if already created) an AjaxResponse to redirect to the passed component with a component action.
|
static void |
setPageReplacementCacheKey(com.webobjects.appserver.WOContext _context,
String _key) |
static boolean |
shouldHandleRequest(com.webobjects.appserver.WORequest request,
com.webobjects.appserver.WOContext context,
String containerID) |
static void |
updateDomElement(com.webobjects.appserver.WOResponse response,
String id,
Object value,
String numberFormat,
String dateFormat,
String valueWhenEmpty)
updateDomElement appends JavaScript code to the given
AjaxResponse that updates the content of the DOM Element with the given
ID to the specified value. |
public static String quote(String value)
value
- the value to quotepublic static boolean isAjaxRequest(com.webobjects.appserver.WORequest request)
request
- the request the checktrue
public static void setPageReplacementCacheKey(com.webobjects.appserver.WOContext _context, String _key)
public static AjaxResponse createResponse(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
request
- the current requestcontext
- the current contextpublic static void addScriptResourceInHead(com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOResponse response, String framework, String fileName)
context
- the contextresponse
- the response to write intoframework
- the framework that contains the filefileName
- the name of the javascript file to addpublic static void addScriptResourceInHead(com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOResponse response, String fileName)
addScriptResourceInHead(WOContext, WOResponse, String, String)
with "Ajax" as framework.context
- the contextresponse
- the response to write intofileName
- the name of the javascript file to addpublic static void addStylesheetResourceInHead(com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOResponse response, String framework, String fileName)
context
- the contextresponse
- the response to write intoframework
- the framework that contains the filefileName
- the name of the CSS file to addpublic static void addStylesheetResourceInHead(com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOResponse response, String fileName)
addStylesheetResourceInHead(WOContext, WOResponse, String, String)
with "Ajax" as framework.context
- the contextresponse
- the response to write intofileName
- the name of the CSS file to addpublic 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 boolean shouldHandleRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context, String containerID)
public static com.webobjects.appserver.WOResponse javascriptResponse(String javascript, com.webobjects.appserver.WOContext context)
AjaxResponse
with the given javascript as the body of the response.context
- the contextjavascript
- the javascript to sendpublic static void appendScript(com.webobjects.appserver.WOContext context, String script)
context
- the contextscript
- the script to appendpublic static void appendScript(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOResponse response, String script)
request
- the requestresponse
- the responsescript
- the script to appendpublic static void appendScriptHeaderIfNecessary(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOResponse response)
public static void appendScriptHeader(com.webobjects.appserver.WOResponse response)
public static void appendScriptFooterIfNecessary(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOResponse response)
public static void appendScriptFooter(com.webobjects.appserver.WOResponse response)
public static <T> NSArray<T> arrayValueForAssociation(com.webobjects.appserver.WOComponent component, com.webobjects.appserver.WOAssociation association)
T
- the array typecomponent
- the component to resolve againstassociation
- the association to retrieve a value forpublic static <T> NSArray<T> arrayValueForBinding(com.webobjects.appserver.WOComponent component, String bindingName)
T
- the array typecomponent
- the component to resolve againstbindingName
- the name of the bindingpublic static <T> NSArray<T> arrayValueForObject(Object value)
T
- the array typevalue
- the object valuepublic static String ajaxComponentActionUrl(com.webobjects.appserver.WOContext context)
context
- the context of the requestpublic static void appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOComponent component, NSDictionary<String,com.webobjects.appserver.WOAssociation> associations, String name)
public static void appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOComponent component, NSDictionary<String,com.webobjects.appserver.WOAssociation> associations, String name, String appendValue)
public static void appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOComponent component, String name, com.webobjects.appserver.WOAssociation association)
public static void appendTagAttributeAndValue(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOComponent component, String name, com.webobjects.appserver.WOAssociation association, String appendValue)
public static void redirectTo(com.webobjects.appserver.WOComponent component)
component
- full page WOComponent instance to redirect topublic static void updateDomElement(com.webobjects.appserver.WOResponse response, String id, Object value, String numberFormat, String dateFormat, String valueWhenEmpty)
updateDomElement
appends JavaScript code to the given
AjaxResponse that updates the content of the DOM Element with the given
ID to the specified value. Useful if you want to update multiple small
regions on a page with a single request, e.g. when an AjaxObserveField
triggers an action.
This method is also available on instances. The example
below uses the method on AjaxResponse.
public WOActionResults cartItemChanged() {
ShoppingCart cart; // assume this exists
ShoppingCartItem item; // assume this exists
AjaxResponse response = AjaxUtils.createResponse(context().request(), context());
response.appendScriptHeaderIfNecessary();
response.updateDomElement("orderAmount_" + item.primaryKey(), item.orderAmount(), "#,##0.", null, null);
response.updateDomElement("price_" + item.primaryKey(), item.priceForOrderAmount(), "#,##0.00", null, null);
response.updateDomElement("shoppingCartPrice", cart.totalPrice(), "#,##0.00", null, null);
response.appendScriptFooterIfNecessary();
return response;
}
response
- The response to append the JavaScript toid
- ID of the DOM element to updatevalue
- The new valuenumberFormat
- optional number format to format the value withdateFormat
- optional date format to format the value withvalueWhenEmpty
- string to use when value is nullAjaxResponse.updateDomElement(String, Object, String, String, String)
,
AjaxResponse.updateDomElement(String, Object)
Copyright © 2002 – 2020 Project Wonder.