Package: org.codehaus.groovy.grails.plugins.web.taglib

## [Groovy] Class JavascriptTagLib

- org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib

- All Implemented Interfaces and Traits:
    org.springframework.context.ApplicationContextAware

      @Artefact("TagLibrary")
      class JavascriptTagLib
      extends java.lang.Object

  Tags for developing javascript and ajax applications.

  Authors:
    Graeme Rocher

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.String` | `INCLUDED_LIBRARIES` | Mappings to the relevant files to be included for each library.

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `static java.lang.String` | `CONTROLLER`
    `static java.lang.String` | `INCLUDED_JS`
    `static java.lang.Object` | `LIBRARY_MAPPINGS`
    `static java.lang.Object` | `PROVIDER_MAPPINGS`
    `org.springframework.context.ApplicationContext` | `applicationContext`
    `CodecLookup` | `codecLookup`
    `java.lang.Class<JavascriptProvider>` | `defaultProvider`
    `static java.lang.Object` | `encodeAsForTags`
    `groovy.lang.Closure` | `escapeJavascript` Escapes a javascript string replacing single/double quotes and new lines.
    `groovy.lang.Closure` | `formRemote` A form which uses the javascript provider to serialize its parameters and submit via an asynchronous ajax call.
    `boolean` | `hasResourceProcessor`
    `groovy.lang.Closure` | `javascript` Includes a javascript src file, library or inline script if the tag has no 'src' or 'library' attributes its assumed to be an inline script:
    `GrailsPluginManager` | `pluginManager`
    `groovy.lang.Closure` | `remoteField` A field that sends its value to a remote link.
    `groovy.lang.Closure` | `remoteFunction` Creates a remote function call.
    `groovy.lang.Closure` | `remoteLink` Creates a link to a remote uri that can be invoked via ajax.
    `groovy.lang.Closure` | `setProvider`
    `groovy.lang.Closure` | `submitToRemote` Creates a form submit button that submits the current form to a remote ajax call.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `JavascriptTagLib ()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### public static final java.lang.String INCLUDED_LIBRARIES

      Mappings to the relevant files to be included for each library.

  - ### Property Detail

    - #### static final java.lang.String CONTROLLER

    - #### static final java.lang.String INCLUDED_JS

    - #### static final java.lang.Object LIBRARY_MAPPINGS

    - #### static final java.lang.Object PROVIDER_MAPPINGS

    - #### org.springframework.context.ApplicationContext applicationContext

    - #### CodecLookup codecLookup

    - #### java.lang.Class<JavascriptProvider> defaultProvider

    - #### static java.lang.Object encodeAsForTags

    - #### groovy.lang.Closure escapeJavascript

      Escapes a javascript string replacing single/double quotes and new lines.
      <g:escapeJavascript>This is some "text" to be escaped</g:escapeJavascript>

    - #### groovy.lang.Closure formRemote

      A form which uses the javascript provider to serialize its parameters and submit via an asynchronous ajax call.

      attr:
        name REQUIRED The form name
      attr:
        url REQUIRED The url to submit to as either a map (containing values for the controller, action, id, and params) or a URL string
      attr:
        action The action to execute as a fallback, defaults to the url if non specified
      attr:
        update Either a map containing the elements to update for 'success' or 'failure' states, or a string with the element to update in which cause failure events would be ignored
      attr:
        before The javascript function to call before the remote function call
      attr:
        after The javascript function to call after the remote function call
      attr:
        asynchronous Whether to do the call asynchronously or not (defaults to true)
      attr:
        method The method to use the execute the call (defaults to "post")

    - #### boolean hasResourceProcessor

    - #### groovy.lang.Closure javascript

      Includes a javascript src file, library or inline script if the tag has no 'src' or 'library' attributes its assumed to be an inline script:
      <g:javascript>alert('hello')</g:javascript>
      The 'library' attribute will attempt to use the library mappings defined above to import the right js files and not duplicate imports eg.
      <g:javascript library="scriptaculous" /> // imports all the necessary js for the scriptaculous library
      The 'src' attribute will merely import the js file but within the right context (ie inside the /js/ directory of the Grails application:
      <g:javascript src="myscript.js" /> // actually imports '/app/js/myscript.js'

      attr:
        src The name of the javascript file to import. Will look in web-app/js dir
      attr:
        library The name of the library to include. e.g. "jquery", "prototype", "scriptaculous", "yahoo" or "dojo"
      attr:
        plugin The plugin to look for the javascript in
      attr:
        contextPath the context path to use (relative to the application context path). Defaults to "" or path to the plugin for a plugin view or template.
      attr:
        base specifies the full base url to prepend to the library name

    - #### GrailsPluginManager pluginManager

    - #### groovy.lang.Closure remoteField

      A field that sends its value to a remote link.

      emptyTag:
        @attr name REQUIRED the name of the field
      attr:
        value The initial value of the field
      attr:
        paramName The name of the parameter send to the server
      attr:
        action the name of the action to use in the link, if not specified the default action will be linked
      attr:
        controller the name of the controller to use in the link, if not specified the current controller will be linked
      attr:
        id The id to use in the link
      attr:
        update Either a map containing the elements to update for 'success' or 'failure' states, or a string with the element to update in which cause failure events would be ignored
      attr:
        before The javascript function to call before the remote function call
      attr:
        after The javascript function to call after the remote function call
      attr:
        asynchronous Whether to do the call asynchronously or not (defaults to true)
      attr:
        method The method to use the execute the call (defaults to "post")

    - #### groovy.lang.Closure remoteFunction

      Creates a remote function call.

      emptyTag:
        @attr before The javascript function to call before the remote function call
      attr:
        after The javascript function to call after the remote function call
      attr:
        update Either a map containing the elements to update for 'success' or 'failure' states, or a string with the element to update in which cause failure events would be ignored
      attr:
        action the name of the action to use in the link, if not specified the default action will be linked
      attr:
        controller the name of the controller to use in the link, if not specified the current controller will be linked
      attr:
        id The id to use in the link
      attr:
        asynchronous Whether to do the call asynchronously or not (defaults to true, specified in 'options' array)
      attr:
        method The method to use the execute the call (defaults to "post")

    - #### groovy.lang.Closure remoteLink

      Creates a link to a remote uri that can be invoked via ajax.

      attr:
        update Either a map containing the elements to update for 'success' or 'failure' states, or a string with the element to update in which cause failure events would be ignored
      attr:
        before The javascript function to call before the remote function call
      attr:
        after The javascript function to call after the remote function call
      attr:
        asynchronous Whether to do the call asynchronously or not (defaults to true)
      attr:
        method The method to use the execute the call (defaults to "post")
      attr:
        controller The name of the controller to use in the link, if not specified the current controller will be linked
      attr:
        action The name of the action to use in the link, if not specified the default action will be linked
      attr:
        uri relative URI
      attr:
        url A map containing the action,controller,id etc.
      attr:
        base Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of the absolute property, if both are specified.
      attr:
        absolute If set to "true" will prefix the link target address with the value of the grails.serverURL property from Config, or http://localhost:<port> if no value in Config and not running in production.
      attr:
        id The id to use in the link
      attr:
        fragment The link fragment (often called anchor tag) to use
      attr:
        params A map containing URL query parameters
      attr:
        mapping The named URL mapping to use to rewrite the link
      attr:
        elementId the DOM element id

    - #### groovy.lang.Closure setProvider

    - #### groovy.lang.Closure submitToRemote

      Creates a form submit button that submits the current form to a remote ajax call.

      attr:
        url The url to submit to, either a map contraining keys for the action,controller and id or string value
      attr:
        update Either a map containing the elements to update for 'success' or 'failure' states, or a string with the element to update in which cause failure events would be ignored
      attr:
        before The javascript function to call before the remote function call
      attr:
        after The javascript function to call after the remote function call
      attr:
        asynchronous Whether to do the call asynchronously or not (defaults to true)
      attr:
        method The method to use the execute the call (defaults to "post")

  - ### Constructor Detail

    - #### JavascriptTagLib()