Package org.zkoss.stateless.sul

## Interface IScript

- All Superinterfaces:
    `IComponent<IScript>`

      public interface IScript
      extends IComponent<IScript>

  Immutable `Script` component

  A component to generate script codes that will be evaluated at the client. It is similar to HTML SCRIPT tag, except the defer option (`withDefer(boolean)`) will cause the evaluation of JavaScript until the widget has been instantiated and mounted to the DOM tree.

  Author:
    katherine
  See Also:
    `Script`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static class` | `IScript.Builder` | Builds instances of type `IScript`.
    `static class` | `IScript.Updater` | Builds an updater of type `IScript` for `UiAgent.smartUpdate(Locator, SmartUpdater)`.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static IScript` | `DEFAULT` | Constant for default attributes of this immutable component.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.String` | `getCharset()` | Returns the character encoding of the source.
    `java.lang.String` | `getContent()` | Returns the content of the script element.
    `java.lang.String` | `getPackages()` | Returns the list of packages to load before evaluating the script defined in `getContent()`.
    `java.lang.String` | `getSrc()` | Returns the URI of the source that contains the script codes.
    `default java.lang.String` | `getWidgetClass()` | Returns the client widget class.
    `default boolean` | `isDefer()` | Returns whether to defer the execution of the script codes until the widget is instantiated and mounted.
    `static IScript` | `of​(java.lang.String content)` | Returns the instance with the given content.
    `static IScript` | `ofId​(java.lang.String id)` | Returns the instance with the given id.
    `static IScript` | `ofSrc​(java.lang.String src)` | Returns the instance with the given src.
    `IScript` | `withCharset​(java.lang.String charset)` | Returns a copy of `this` immutable component with the specified `charset`.
    `IScript` | `withContent​(java.lang.String content)` | Returns a copy of `this` immutable component with the specified `content`.
    `IScript` | `withDefer​(boolean defer)` | Returns a copy of `this` immutable component with the specified `defer`.
    `IScript` | `withPackages​(java.lang.String packages)` | Returns a copy of `this` immutable component with the specified `packages`.
    `IScript` | `withSrc​(java.lang.String charset)` | Returns a copy of `this` immutable component with the specified `charset`.

    - ### Methods inherited from interface org.zkoss.stateless.sul.IComponent

      `getAction, getActions, getClientAttributes, getId, getMold, getWidgetListeners, getWidgetOverrides, isVisible, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withAction, withActions, withActions, withClientAttribute, withClientAttributes, withId, withMold, withVisible, withWidgetClass, withWidgetListener, withWidgetListeners, withWidgetOverride, withWidgetOverrides`

- - ### Field Detail

    - #### DEFAULT

          static final IScript DEFAULT

      Constant for default attributes of this immutable component.

  - ### Method Detail

    - #### getWidgetClass

          default java.lang.String getWidgetClass()

      Returns the client widget class.

      Default: `"zul.utl.Script"`

      Specified by:
        `getWidgetClass` in interface `IComponent<IScript>`
      Returns:

    - #### getCharset

          @Nullable
          java.lang.String getCharset()

      Returns the character encoding of the source. It is used with `getSrc()`.

      Default: `null`.

    - #### withCharset

          IScript withCharset​(@Nullable
                              java.lang.String charset)

      Returns a copy of `this` immutable component with the specified `charset`.

      Sets the character encoding of the source. It is used with `withSrc(java.lang.String)`.

      Refer to HTML Character Setsfor more information.

      Parameters:
        `charset` - The character encoding of the source.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### getSrc

          @Nullable
          java.lang.String getSrc()

      Returns the URI of the source that contains the script codes.

      Default: `null`.

    - #### withSrc

          IScript withSrc​(@Nullable
                          java.lang.String charset)

      Returns a copy of `this` immutable component with the specified `charset`.

      Sets the URI of the source that contains the script codes.

      Parameters:
        `charset` - The character encoding of the source.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### isDefer

          default boolean isDefer()

      Returns whether to defer the execution of the script codes until the widget is instantiated and mounted.

      Default: `false`.

      Specifying false (default), if you want to do the desktop-level (or class-level) initialization, such as defining a widget class or a global function.

      Specifying true, if you want to access widgets. Notice that `this` references to this script widget.

    - #### withDefer

          IScript withDefer​(boolean defer)

      Returns a copy of `this` immutable component with the specified `defer`.

      Sets whether to defer the execution of the script codes.

      Parameters:
        `defer` - Whether to defer the execution of the script codes.

        Default: `false`.

      Returns:
        A modified copy of the `this` object

    - #### getContent

          @Nullable
          java.lang.String getContent()

      Returns the content of the script element. By content we mean the JavaScript codes that will be enclosed by the HTML SCRIPT element.

      Default: `null`.

    - #### withContent

          IScript withContent​(@Nullable
                              java.lang.String content)

      Returns a copy of `this` immutable component with the specified `content`.

      Sets the content of the script element. By content we mean the JavaScript codes that will be enclosed by the HTML SCRIPT element.

      Parameters:
        `content` - The content of the script element.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### getPackages

          @Nullable
          java.lang.String getPackages()

      Returns the list of packages to load before evaluating the script defined in `getContent()`. It is meaning only if `getContent()` not null.

      Default: `null`.

    - #### withPackages

          IScript withPackages​(@Nullable
                               java.lang.String packages)

      Returns a copy of `this` immutable component with the specified `packages`.

      Sets the list of packages to load before evaluating the script defined in `getContent()`. If more than a package to load, separate them with comma.

      Parameters:
        `packages` - The list of packages to load before evaluating the script.

        Default: `null`.

      Returns:
        A modified copy of the `this` object

    - #### of

          static IScript of​(java.lang.String content)

      Returns the instance with the given content.
      Parameters:
        `content` - The script content.

    - #### ofSrc

          static IScript ofSrc​(java.lang.String src)

      Returns the instance with the given src.
      Parameters:
        `src` - The script URI.

    - #### ofId

          static IScript ofId​(java.lang.String id)

      Returns the instance with the given id.
      Parameters:
        `id` - The id to identify this component