public class AjaxOptions
extends com.webobjects.appserver.WODynamicElement
new Ajax.Request('/some_url', { method: 'get', parameters: {company: 'example', limit: 12} });However, the functionality is not specific to Prototype and can be used anywhere a JSON formatted dictionary is needed.
AjaxOptions can be used either in a HTML/WOD setting, e.g.
AjaxOptions : AjaxOptions { method = "get"; options = createAjaxOptions; }with options bound to a dictionary produced by AjaxOption, or it can be used directly in Java, e.g.
AjaxOptions.appendToResponse(createAjaxOptions(), context.response(), context);
Example (and fictitious) usage code:
public NSDictionary createAjaxOptions(WOComponent component) {
NSMutableArray<AjaxOption> ajaxOptionsArray = new NSMutableArray<>();
ajaxOptionsArray.addObject(new AjaxOption("frequency", AjaxOption.NUMBER));
ajaxOptionsArray.addObject(new AjaxOption("onLoading", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("evalScripts", Boolean.TRUE, AjaxOption.BOOLEAN));
ajaxOptionsArray.addObject(new AjaxOption("method", "get", AjaxOption.STRING));
...
NSMutableDictionary<String, String> options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, component, associations());
return options;
}
response.appendContentString("AUC.registerPeriodic('" + id + "'," + canStop + "," + stopped + ",");
AjaxOptions.appendToResponse(options, response, context);
response.appendContentString(");");
AjaxOption
,
AjaxValue
Constructor and Description |
---|
AjaxOptions(String name,
NSDictionary<String,com.webobjects.appserver.WOAssociation> bindings,
com.webobjects.appserver.WOElement children) |
Modifier and Type | Method and Description |
---|---|
static void |
_appendToBuffer(NSDictionary options,
Appendable appendable,
com.webobjects.appserver.WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
static void |
_appendToResponse(NSDictionary options,
com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
static void |
appendToBuffer(NSDictionary options,
Appendable appendable,
com.webobjects.appserver.WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
static void |
appendToResponse(NSDictionary options,
com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
void |
appendToResponse(com.webobjects.appserver.WOResponse response,
com.webobjects.appserver.WOContext context) |
public AjaxOptions(String name, NSDictionary<String,com.webobjects.appserver.WOAssociation> bindings, com.webobjects.appserver.WOElement children)
public void appendToResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
appendToResponse
in class com.webobjects.appserver.WOElement
public static void _appendToResponse(NSDictionary options, com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
options
- dictionary of key-value pairs, intended to have come from AjaxOptionresponse
- WOResponse to add JSON formatted key-value pairs tocontext
- WOContext to provide WOComponent to resolve binding values inpublic static void _appendToBuffer(NSDictionary options, Appendable appendable, com.webobjects.appserver.WOContext context)
options
- dictionary of key-value pairs, intended to have come from AjaxOptionappendable
- appendable to add JSON formatted key-value pairs tocontext
- WOContext to provide WOComponent to resolve binding values inpublic static void appendToBuffer(NSDictionary options, Appendable appendable, com.webobjects.appserver.WOContext context)
options
- dictionary of key-value pairs, intended to have come from AjaxOptionappendable
- appendable to add JSON formatted key-value pairs tocontext
- WOContext to provide WOComponent to resolve binding values inpublic static void appendToResponse(NSDictionary options, com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
options
- dictionary of key-value pairs, intended to have come from AjaxOptionresponse
- WOResponse to add JSON formatted key-value pairs tocontext
- WOContext to provide WOComponent to resolve binding values inCopyright © 2002 – 2020 Project Wonder.