C# Class Castle.MonoRail.Framework.Helpers.AjaxHelper

MonoRail Helper that delivers AJAX capabilities.
The following libraries are exposed: Prototype Simplify ajax programming, among other goodies Behaviour Uses css selectors to bind javascript code to DOM elements
Inheritance: AbstractHelper, IServiceEnabledComponent
Exibir arquivo Open project: nats/castle-1.0.3-mono Class Usage Examples

Public Methods

Method Description
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.

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

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).

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).

BuildRemoteFunction ( String url, IDictionary options ) : String

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

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.

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.

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

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

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

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

GenerateJSProxy ( string proxyName ) : String

Generates an AJAX JavaScript proxy for the current controller.

GenerateJSProxy ( string proxyName, string controller ) : String

Generates an AJAX JavaScript proxy for a given controller.

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

Generates an AJAX JavaScript proxy for a given controller.

GetOptions ( String url, IDictionary options ) : IDictionary

Gets the options.

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

Gets the options.

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:

input The text input element id url url to to call when the field has changed

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

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. AutoCompleteInputText

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

InstallScripts ( ) : String

Renders a Javascript library inside a single script tag.

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.

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>

LinkToFunction ( String innerContent, String functionCodeOrName, String confirm ) : String

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

LinkToFunction ( String innerContent, String functionCodeOrName, string confirm, 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="confirm('question') { functionCodeOrName}; return false">innerContent</a>

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

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

LinkToRemote ( String innerContent, String confirm, 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

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:

field The DOM field to be observed url url to to call when the field has changed frequency The frequency (in seconds) at which changes to this field will be detected

The following are optional entries:

update 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, int 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.

ObserveField ( String fieldId, int 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.

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:

form The form element id url url to to call when the field has changed frequency The frequency (in seconds) at which changes to this field will be detected

The following are optional entries:

update 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 ObserveField(IDictionary), but operates on an entire form identified by the DOM ID formId. options are the same as ObserveField(IDictionary), except the default value of the with option evaluates to the serialized (request String) value of the entire form.

ObserveForm ( String formId, int frequency, String url, String idOfElementToBeUpdated, object with ) : String

Like ObserveField(IDictionary), but operates on an entire form identified by the DOM ID formId. options are the same as ObserveField(IDictionary), except the default value of the :with option evaluates to the serialized (request String) value of the form. Works like the ObserveField(IDictionary), but operates on an entire form identified by the DOM ID formId. Options are the same as ObserveField(IDictionary), except the default value of the with option evaluates to the serialized (request String) value of the entire form.

PeriodicallyCallRemote ( IDictionary options ) : String

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

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).

RemoteFunction ( IDictionary options ) : String

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

Service ( IServiceProvider provider ) : void

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

Protected Methods

Method Description
BuildAjaxOptions ( IDictionary jsOptions, IDictionary options ) : String

Populates the jsOptions by analyzing the options set on the helper options

The following options are analyzed type boolean - sets the asynchronous method string - sets the method. Possible values are post/get evalScripts boolean position string - sets the place where content is inserted (Top, Bottom, After, Before) form if present, set the parameters request to send the current form serialized with if present, set its content as the parameters for the ajax request

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

Builds the callback function.

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

Builds the observer.

Private Methods

Method Description
BuildCallbacks ( IDictionary jsOptions, IDictionary options ) : void
GetJavascriptFunctions ( ) : String
GetUrlOption ( IDictionary options ) : String
ProcessWith ( object with ) : string

Method Details

AutoCompleteInputText() public method

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.
it is assumed that the url invoked returns an unordered list.
public AutoCompleteInputText ( String elementId, String url, IDictionary options ) : String
elementId String The element id (input type=text)
url String The url to be invoked returning results
options IDictionary the options for the Ajax invocation
return String

BuildAjaxOptions() protected method

Populates the jsOptions by analyzing the options set on the helper options
The following options are analyzed type boolean - sets the asynchronous method string - sets the method. Possible values are post/get evalScripts boolean position string - sets the place where content is inserted (Top, Bottom, After, Before) form if present, set the parameters request to send the current form serialized with if present, set its content as the parameters for the ajax request
protected BuildAjaxOptions ( IDictionary jsOptions, IDictionary options ) : String
jsOptions IDictionary Options that will be used on the js side
options IDictionary Options passed to the helper method
return String

BuildCallbackFunction() protected method

Builds the callback function.
protected BuildCallbackFunction ( CallbackEnum callback, String code, String &name ) : String
callback CallbackEnum The callback.
code String The code.
name String The name.
return String

BuildFormRemoteTag() public method

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).
public BuildFormRemoteTag ( IDictionary options ) : String
options IDictionary the options for the Ajax invocation
return String

BuildFormRemoteTag() public method

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).
public BuildFormRemoteTag ( String url, IDictionary options ) : String
url String Target url
options IDictionary the options for the Ajax invocation
return String

BuildObserver() protected method

Builds the observer.
protected BuildObserver ( String clazz, String name, IDictionary options ) : String
clazz String The clazz.
name String The name.
options IDictionary The options.
return String

BuildRemoteFunction() public method

Returns a function that makes a remote invocation, using the supplied parameters
public BuildRemoteFunction ( String url, IDictionary options ) : String
url String Target url
options IDictionary the options for the Ajax invocation
return String

ButtonToFunction() public method

Returns a button that will trigger a javascript function using the onclick handler and return false after the fact.
public ButtonToFunction ( String innerContent, String functionCodeOrName ) : String
innerContent String Button legend
functionCodeOrName String Function definition or name
return String

ButtonToFunction() public method

Returns a button that will trigger a javascript function using the onclick handler and return false after the fact.
public ButtonToFunction ( String innerContent, String functionCodeOrName, IDictionary attributes ) : String
innerContent String Button legend
functionCodeOrName String Function definition or name
attributes IDictionary Attributes to be applied to the input html element
return String

ButtonToRemote() public method

Creates a button that if clicked will fire an Ajax invocation.
public ButtonToRemote ( String innerContent, String url, IDictionary options ) : String
innerContent String Button legend
url String The URL of the Ajax action
options IDictionary the options for the Ajax invocation
return String

ButtonToRemote() public method

Creates a button that if clicked will fire an Ajax invocation.
public ButtonToRemote ( String innerContent, String url, IDictionary options, IDictionary htmloptions ) : String
innerContent String Button legend
url String the target url
options IDictionary the options for the Ajax invocation
htmloptions IDictionary Attributes to be applied to the html element
return String

GenerateJSProxy() public method

Generates an AJAX JavaScript proxy for the current controller.
public GenerateJSProxy ( string proxyName ) : String
proxyName string Name of the javascript proxy object
return String

GenerateJSProxy() public method

Generates an AJAX JavaScript proxy for a given controller.
public GenerateJSProxy ( string proxyName, string controller ) : String
proxyName string Name of the javascript proxy object
controller string Controller which will be target of the proxy
return String

GenerateJSProxy() public method

Generates an AJAX JavaScript proxy for a given controller.
public GenerateJSProxy ( string proxyName, string area, string controller ) : String
proxyName string Name of the javascript proxy object
area string area which the controller belongs to
controller string Controller which will be target of the proxy
return String

GetOptions() public method

Gets the options.
public GetOptions ( String url, IDictionary options ) : IDictionary
url String The URL.
options IDictionary The options.
return IDictionary

GetOptions() public method

Gets the options.
public GetOptions ( String url, String idOfElementToBeUpdated, object with, String loading, String loaded, String complete, String interactive ) : IDictionary
url String The URL.
idOfElementToBeUpdated String The id of element to be updated.
with object The with.
loading String The loading.
loaded String The loaded.
complete String The complete.
interactive String The interactive.
return IDictionary

InputTextWithAutoCompletion() public method

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:

input The text input element id url url to to call when the field has changed
it is assumed that the url invoked returns an unordered list.
public InputTextWithAutoCompletion ( IDictionary options, IDictionary tagAttributes ) : String
options IDictionary the options for the Ajax invocation
tagAttributes IDictionary attributes for the input html element
return String

InputTextWithAutoCompletion() public method

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. AutoCompleteInputText
it is assumed that the url invoked returns an unordered list.
public InputTextWithAutoCompletion ( String inputName, String url, IDictionary tagAttributes, IDictionary completionOptions ) : String
inputName String input element id
url String url used to gather results
tagAttributes IDictionary attributes for the input element
completionOptions IDictionary options for the autocomplete
return String

InstallScripts() public method

Renders a Javascript library inside a single script tag.
public InstallScripts ( ) : String
return String

LinkToFunction() public method

Returns a link that will trigger a javascript function using the onclick handler and return false after the fact.
public LinkToFunction ( String innerContent, String functionCodeOrName ) : String
innerContent String Link content
functionCodeOrName String Function definition
return String

LinkToFunction() public method

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>
public LinkToFunction ( String innerContent, String functionCodeOrName, IDictionary attributes ) : String
innerContent String Link content
functionCodeOrName String Function definition
attributes IDictionary Attributes to be applied to the html element
return String

LinkToFunction() public method

Returns a link that will trigger a javascript function using the onclick handler and return false after the fact.
public LinkToFunction ( String innerContent, String functionCodeOrName, String confirm ) : String
innerContent String Link content
functionCodeOrName String Function definition
confirm String Confirm question
return String

LinkToFunction() public method

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="confirm('question') { functionCodeOrName}; return false">innerContent</a>
public LinkToFunction ( String innerContent, String functionCodeOrName, string confirm, IDictionary attributes ) : String
innerContent String Link content
functionCodeOrName String Function definition
confirm string Confirm question
attributes IDictionary Attributes to be applied to the html element
return String

LinkToRemote() public method

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
public LinkToRemote ( String innerContent, String url, IDictionary options ) : String
innerContent String Link content
url String Target url
options IDictionary the options for the Ajax invocation
return String

LinkToRemote() public method

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
public LinkToRemote ( String innerContent, String url, IDictionary options, IDictionary htmloptions ) : String
innerContent String Link content
url String Target url
options IDictionary the options for the Ajax invocation
htmloptions IDictionary Attributes to be applied to the html element
return String

LinkToRemote() public method

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
public LinkToRemote ( String innerContent, String confirm, String url, IDictionary options ) : String
innerContent String Link content
confirm String the confirm question
url String Target url
options IDictionary the options for the Ajax invocation
return String

ObserveField() public method

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:

field The DOM field to be observed url url to to call when the field has changed frequency The frequency (in seconds) at which changes to this field will be detected

The following are optional entries:

update 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
public ObserveField ( IDictionary options ) : String
options IDictionary the options for the Ajax invocation
return String

ObserveField() public method

Observes the field with the DOM ID specified by fieldId and makes an Ajax when its contents have changed.
public ObserveField ( String fieldId, int frequency, String url, IDictionary options ) : String
fieldId String Form field to be observed
frequency int The frequency (in seconds) at which changes to /// this field will be detected. (required)
url String url for the action to call /// when the field has changed (required)
options IDictionary the options for the Ajax invocation
return String

ObserveField() public method

Observes the field with the DOM ID specified by fieldId and makes an Ajax when its contents have changed.
public ObserveField ( String fieldId, int frequency, String url, String idOfElementToBeUpdated, String with ) : String
fieldId String Form field to be observed
frequency int The frequency (in seconds) at which changes to /// this field will be detected. (required)
url String url for the action to call /// when the field has changed (required)
idOfElementToBeUpdated String Specifies the DOM ID of the element whose /// innerHTML should be updated with the /// XMLHttpRequest response text.
with String A Javascript expression specifying the /// parameters for the XMLHttpRequest. This defaults /// to 'value', which in the evaluated context /// refers to the new field value.
return String

ObserveForm() public method

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:

form The form element id url url to to call when the field has changed frequency The frequency (in seconds) at which changes to this field will be detected

The following are optional entries:

update 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
public ObserveForm ( IDictionary options ) : String
options IDictionary the options for the Ajax invocation
return String

ObserveForm() public method

Like ObserveField(IDictionary), but operates on an entire form identified by the DOM ID formId. options are the same as ObserveField(IDictionary), except the default value of the with option evaluates to the serialized (request String) value of the entire form.
public ObserveForm ( String formId, IDictionary options ) : String
formId String Form to be observed
options IDictionary the options for the Ajax invocation
return String

ObserveForm() public method

Like ObserveField(IDictionary), but operates on an entire form identified by the DOM ID formId. options are the same as ObserveField(IDictionary), except the default value of the :with option evaluates to the serialized (request String) value of the form. Works like the ObserveField(IDictionary), but operates on an entire form identified by the DOM ID formId. Options are the same as ObserveField(IDictionary), except the default value of the with option evaluates to the serialized (request String) value of the entire form.
public ObserveForm ( String formId, int frequency, String url, String idOfElementToBeUpdated, object with ) : String
formId String Form to be observed
frequency int The frequency (in seconds) at which changes to /// this field will be detected. (required)
url String url for the action to call /// when the field has changed (required)
idOfElementToBeUpdated String Specifies the DOM ID of the element whose /// innerHTML should be updated with the /// XMLHttpRequest response text.
with object A Javascript expression specifying the /// parameters for the XMLHttpRequest. This defaults /// to 'value', which in the evaluated context /// refers to the new field value.
return String

PeriodicallyCallRemote() public method

Periodically invokes the specified url. You can use the options to override the default frequency (defaults to 10 seconds).
public PeriodicallyCallRemote ( IDictionary options ) : String
options IDictionary the options for the Ajax invocation
return String

PeriodicallyCallRemote() public method

Periodically invokes the specified url. You can use the options to override the default frequency (defaults to 10 seconds).
public PeriodicallyCallRemote ( String url, IDictionary options ) : String
url String url to be invoked periodically
options IDictionary the options for the Ajax invocation
return String

RemoteFunction() public method

Returns a function that makes a remote invocation, using the supplied parameters
public RemoteFunction ( IDictionary options ) : String
options IDictionary the options for the Ajax invocation
return String

Service() public method

Invoked by the framework in order to give a chance to obtain other services
public Service ( IServiceProvider provider ) : void
provider IServiceProvider The service proviver
return void