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
Afficher le fichier Open project: nats/castle-1.0.3-mono Class Usage Examples

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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

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

Method Details

AutoCompleteInputText() public méthode

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
Résultat String

BuildAjaxOptions() protected méthode

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
Résultat String

BuildCallbackFunction() protected méthode

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.
Résultat String

BuildFormRemoteTag() public méthode

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
Résultat String

BuildFormRemoteTag() public méthode

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
Résultat String

BuildObserver() protected méthode

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

BuildRemoteFunction() public méthode

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
Résultat String

ButtonToFunction() public méthode

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
Résultat String

ButtonToFunction() public méthode

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
Résultat String

ButtonToRemote() public méthode

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
Résultat String

ButtonToRemote() public méthode

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
Résultat String

GenerateJSProxy() public méthode

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

GenerateJSProxy() public méthode

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
Résultat String

GenerateJSProxy() public méthode

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
Résultat String

GetOptions() public méthode

Gets the options.
public GetOptions ( String url, IDictionary options ) : IDictionary
url String The URL.
options IDictionary The options.
Résultat IDictionary

GetOptions() public méthode

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.
Résultat IDictionary

InputTextWithAutoCompletion() public méthode

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
Résultat String

InputTextWithAutoCompletion() public méthode

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
Résultat String

InstallScripts() public méthode

Renders a Javascript library inside a single script tag.
public InstallScripts ( ) : String
Résultat String

LinkToFunction() public méthode

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
Résultat String

LinkToFunction() public méthode

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
Résultat String

LinkToFunction() public méthode

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
Résultat String

LinkToFunction() public méthode

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
Résultat String

LinkToRemote() public méthode

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
Résultat String

LinkToRemote() public méthode

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
Résultat String

LinkToRemote() public méthode

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
Résultat String

ObserveField() public méthode

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
Résultat String

ObserveField() public méthode

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
Résultat String

ObserveField() public méthode

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.
Résultat String

ObserveForm() public méthode

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
Résultat String

ObserveForm() public méthode

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
Résultat String

ObserveForm() public méthode

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.
Résultat String

PeriodicallyCallRemote() public méthode

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
Résultat String

PeriodicallyCallRemote() public méthode

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
Résultat String

RemoteFunction() public méthode

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
Résultat String

Service() public méthode

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