public class AjaxOptions extends 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
_ConstructorParameters
Constructor and Description |
---|
AjaxOptions(String name,
NSDictionary<String,WOAssociation> bindings,
WOElement children) |
Modifier and Type | Method and Description |
---|---|
static void |
_appendToBuffer(NSDictionary options,
Appendable appendable,
WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
static void |
_appendToResponse(NSDictionary options,
WOResponse response,
WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
static void |
appendToBuffer(NSDictionary options,
Appendable appendable,
WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
static void |
appendToResponse(NSDictionary options,
WOResponse response,
WOContext context)
Adds JSON formatted key-value pairs from options to end of response content.
|
void |
appendToResponse(WOResponse response,
WOContext context) |
toString
invokeAction, takeValuesFromRequest
public AjaxOptions(String name, NSDictionary<String,WOAssociation> bindings, WOElement children)
public void appendToResponse(WOResponse response, WOContext context)
appendToResponse
in class WOElement
public static void _appendToResponse(NSDictionary options, WOResponse response, 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, 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, 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, WOResponse response, 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 – 2024 Project Wonder.