Home

Castle Stronghold

Table of contents

AjaxHelper API Document

MonoRail Helper that delivers AJAX capabilities.

Quick Note

The following libraries are exposed: Prototype Simplify ajax programming, among other goodies Behaviour Uses css selectors to bind javascript code to DOM elements

Constructors

AjaxHelper()

Initializes a new instance of the Castle.MonoRail.Framework.Helpers.AjaxHelper class.

Methods

Service(IServiceProvider provider)

Invoked by the framework in order to give a chance to obtain other services

ParameterDescription
provider The service proviver

InstallScripts() : String

Renders a Javascript library inside a single script tag.

GetBehaviourFunctions() : String

Renders a script tag refering the Behaviour library code.

ReApply() : String

Renders a script block invoking Behaviour.apply()

AddLoadEvent(String loadFunctionName) : String

Renders a script block invoking Behaviour.addLoadEvent(loadFunctionName);

ParameterDescription
loadFunctionName The name of the js function to be invoked when the body is loaded

StartBehaviourRegister() : String

Renders a script block starting the association of events to selector rules

Register(String selector, String eventName, String jsFunctionName) : String

Adds a entry to a registration array. Invoking it with #form, onsubmit and validate will produce '#form' : function(e){ e.onsubmit = validate; },

ParameterDescription
selector The css selector rule
eventName The name of the event on the element
jsFunctionName The function to be invoked in response to the event

EndBehaviourRegister() : String

Renders the end of a script block that associated events to selector rules

GenerateJSProxy(String proxyName) : String

Generates an AJAX JavaScript proxy for the current controller.

ParameterDescription
proxyName Name of the javascript proxy object

GenerateJSProxy(String proxyName, String controller) : String

Generates an AJAX JavaScript proxy for a given controller.

ParameterDescription
proxyName Name of the javascript proxy object
controller Controller which will be target of the proxy

GenerateJSProxy(String proxyName, String area, String controller) : String

Generates an AJAX JavaScript proxy for a given controller.

ParameterDescription
proxyName Name of the javascript proxy object
area area which the controller belongs to
controller Controller which will be target of the proxy

LinkToFunction(String innerContent, String functionCodeOrName, IDictionary attributes) : String

Returns a link that will trigger a javascript function using the onclick handler and return false after the fact.


<a href="javascript:void(0);" onclick="functionCodeOrName; return false">innerContent</a>

ParameterDescription
innerContent Link content
functionCodeOrName Function definition
attributes Attributes to be applied to the html element

LinkToFunction(String innerContent, String functionCodeOrName) : String

Returns a link that will trigger a javascript function using the onclick handler and return false after the fact.

ParameterDescription
innerContent Link content
functionCodeOrName Function definition

ButtonToFunction(String innerContent, String functionCodeOrName, IDictionary attributes) : String

Returns a button that will trigger a javascript function using the onclick handler and return false after the fact.

ParameterDescription
innerContent Button legend
functionCodeOrName Function definition or name
attributes Attributes to be applied to the input html element

ButtonToFunction(String innerContent, String functionCodeOrName) : String

Returns a button that will trigger a javascript function using the onclick handler and return false after the fact.

ParameterDescription
innerContent Button legend
functionCodeOrName Function definition or name

ButtonToRemote(String innerContent, String url, IDictionary options) : String

Creates a button that if clicked will fire an Ajax invocation.

ParameterDescription
innerContent Button legend
url The URL of the Ajax action
options the options for the Ajax invocation

ButtonToRemote(String innerContent, String url, IDictionary options, IDictionary htmloptions) : String

Creates a button that if clicked will fire an Ajax invocation.

ParameterDescription
innerContent Button legend
url the target url
options the options for the Ajax invocation
htmloptions Attributes to be applied to the html element

LinkToRemote(String innerContent, String url, IDictionary options) : String

Returns a link to a remote action defined by options["url"] that is called in the background using XMLHttpRequest. The result of that request can then be inserted into a DOM object whose id can be specified with options["update"]. Usually, the result would be a partial prepared by the controller

ParameterDescription
innerContent Link content
url Target url
options the options for the Ajax invocation

LinkToRemote(String innerContent, String url, IDictionary options, IDictionary htmloptions) : String

Returns a link to a remote action defined by options["url"] that is called in the background using XMLHttpRequest. The result of that request can then be inserted into a DOM object whose id can be specified with options["update"]. Usually, the result would be a partial prepared by the controller

ParameterDescription
innerContent Link content
url Target url
options the options for the Ajax invocation
htmloptions Attributes to be applied to the html element

BuildFormRemoteTag(String url, IDictionary options) : String

Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular reloading POST arrangement. Even though it is using Javascript to serialize the form elements, the form submission will work just like a regular submission as viewed by the receiving side (all elements available).

ParameterDescription
url Target url
options the options for the Ajax invocation

BuildFormRemoteTag(IDictionary options) : String

Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular reloading POST arrangement. Even though it is using Javascript to serialize the form elements, the form submission will work just like a regular submission as viewed by the receiving side (all elements available).

ParameterDescription
options the options for the Ajax invocation

ObserveField(String fieldId, Int32 frequency, String url, String idOfElementToBeUpdated, String with) : String

Observes the field with the DOM ID specified by fieldId and makes an Ajax when its contents have changed.

ParameterDescription
fieldId Form field to be observed
frequency The frequency (in seconds) at which changes to this field will be detected. (required)
url url for the action to call when the field has changed (required)
idOfElementToBeUpdated Specifies the DOM ID of the element whose innerHTML should be updated with the XMLHttpRequest response text.
with A Javascript expression specifying the parameters for the XMLHttpRequest. This defaults to 'value', which in the evaluated context refers to the new field value.

ObserveField(String fieldId, Int32 frequency, String url, IDictionary options) : String

Observes the field with the DOM ID specified by fieldId and makes an Ajax when its contents have changed.

ParameterDescription
fieldId Form field to be observed
frequency The frequency (in seconds) at which changes to this field will be detected. (required)
url url for the action to call when the field has changed (required)
options the options for the Ajax invocation

ObserveField(IDictionary options) : String

Observes the field with the DOM ID specified by field and makes an Ajax call when its contents changes.

The following entries must exist in the dictionary:

fieldThe DOM field to be observedurlurl to to call when the field has changedfrequencyThe frequency (in seconds) at which changes to this field will be detected

The following are optional entries:

updateSpecifies the DOM ID of the element whose innerHTML should be updated with the XMLHttpRequest response textwithA Javascript expression specifying the parameters for the XMLHttpRequest. This defaults to 'value', which in the evaluated context refers to the new field value

ParameterDescription
options the options for the Ajax invocation

ObserveForm(String formId, Int32 frequency, String url, String idOfElementToBeUpdated, String with) : String

Works like the Castle.MonoRail.Framework.Helpers.AjaxHelper.ObserveField(System.String,System.Int32,System.String,System.String,System.String), but operates on an entire form identified by the DOM ID formId. Options are the same as Castle.MonoRail.Framework.Helpers.AjaxHelper.ObserveField(System.String,System.Int32,System.String,System.String,System.String), except the default value of the with option evaluates to the serialized (request String) value of the entire form.

ParameterDescription
formId Form to be observed
frequency The frequency (in seconds) at which changes to this field will be detected. (required)
url url for the action to call when the field has changed (required)
idOfElementToBeUpdated Specifies the DOM ID of the element whose innerHTML should be updated with the XMLHttpRequest response text.
with A Javascript expression specifying the parameters for the XMLHttpRequest. This defaults to 'value', which in the evaluated context refers to the new field value.

ObserveForm(String formId, IDictionary options) : String

Like Castle.MonoRail.Framework.Helpers.AjaxHelper.ObserveField(System.String,System.Int32,System.String,System.String,System.String), but operates on an entire form identified by the DOM ID formId. options are the same as Castle.MonoRail.Framework.Helpers.AjaxHelper.ObserveField(System.String,System.Int32,System.String,System.String,System.String), except the default value of the with option evaluates to the serialized (request String) value of the entire form.

ParameterDescription
formId Form to be observed
options the options for the Ajax invocation

ObserveForm(IDictionary options) : String

Observes all elements within a form with the DOM ID specified by form and makes an Ajax call when its contents changes.

The following entries must exist in the dictionary:

formThe form element idurlurl to to call when the field has changedfrequencyThe frequency (in seconds) at which changes to this field will be detected

The following are optional entries:

updateSpecifies the DOM ID of the element whose innerHTML should be updated with the XMLHttpRequest response textwithA Javascript expression specifying the parameters for the XMLHttpRequest. This defaults to 'value', which in the evaluated context refers to the new field value

ParameterDescription
options the options for the Ajax invocation

PeriodicallyCallRemote(IDictionary options) : String

Periodically invokes the specified url. You can use the options to override the default frequency (defaults to 10 seconds).

ParameterDescription
options the options for the Ajax invocation

PeriodicallyCallRemote(String url, IDictionary options) : String

Periodically invokes the specified url. You can use the options to override the default frequency (defaults to 10 seconds).

ParameterDescription
url url to be invoked periodically
options the options for the Ajax invocation

InputTextWithAutoCompletion(IDictionary options, IDictionary tagAttributes) : String

Rendes a input field with Google style autocomplete enabled. The specified url is used to gather the contents for the auto complete panel, so and your action should return filtered and sorted results.

The following entries must exist in the options:

inputThe text input element idurlurl to to call when the field has changed

Quick Note

it is assumed that the url invoked returns an unordered list.

ParameterDescription
options the options for the Ajax invocation
tagAttributes attributes for the input html element

InputTextWithAutoCompletion(String inputName, String url, IDictionary tagAttributes, IDictionary completionOptions) : String

Rendes a input field with Google style autocomplete enabled. The specified url is used to gather the contents for the auto complete panel, so and your action should return filtered and sorted results.

Quick Note

it is assumed that the url invoked returns an unordered list.

ParameterDescription
inputName input element id
url url used to gather results
tagAttributes attributes for the input element
completionOptions options for the autocomplete

AutoCompleteInputText(String elementId, String url, IDictionary options) : String

Generates an javascript block enabling auto completion for the specified input text id (elementId). You can specify the element to be updated using the options dictionary (key update), if you don't we assume elementId+autocomplete.

Quick Note

it is assumed that the url invoked returns an unordered list.

ParameterDescription
elementId The element id (input type=text)
url The url to be invoked returning results
options the options for the Ajax invocation

BuildRemoteFunction(String url, IDictionary options) : String

Returns a function that makes a remote invocation, using the supplied parameters

ParameterDescription
url Target url
options the options for the Ajax invocation

RemoteFunction(IDictionary options) : String

Returns a function that makes a remote invocation, using the supplied parameters

ParameterDescription
options the options for the Ajax invocation

BuildAjaxOptions(IDictionary jsOptions, IDictionary options) : String

Missing summary

ParameterDescription
jsOptions Missing documentation
options Missing documentation

BuildCallbackFunction(CallbackEnum callback, String code, String name) : String

Missing summary

ParameterDescription
callback Missing documentation
code Missing documentation
name Missing documentation

BuildObserver(String clazz, String name, IDictionary options) : String

Missing summary

ParameterDescription
clazz Missing documentation
name Missing documentation
options Missing documentation

GetOptions(String url, IDictionary options) : IDictionary

Missing summary

ParameterDescription
url Missing documentation
options Missing documentation

GetOptions(String url, String idOfElementToBeUpdated, String with, String loading, String loaded, String complete, String interactive) : IDictionary

Missing summary

ParameterDescription
url Missing documentation
idOfElementToBeUpdated Missing documentation
with Missing documentation
loading Missing documentation
loaded Missing documentation
complete Missing documentation
interactive Missing documentation

Google
Search WWW Search castleproject.org