Interface IScript
-
- All Superinterfaces:
IComponent<IScript>
public interface IScript extends IComponent<IScript>
ImmutableScriptcomponentA 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 classIScript.BuilderBuilds instances of typeIScript.static classIScript.UpdaterBuilds an updater of typeIScriptforUiAgent.smartUpdate(Locator, SmartUpdater).
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.StringgetCharset()Returns the character encoding of the source.java.lang.StringgetContent()Returns the content of the script element.java.lang.StringgetPackages()Returns the list of packages to load before evaluating the script defined ingetContent().java.lang.StringgetSrc()Returns the URI of the source that contains the script codes.default java.lang.StringgetWidgetClass()Returns the client widget class.default booleanisDefer()Returns whether to defer the execution of the script codes until the widget is instantiated and mounted.static IScriptof(java.lang.String content)Returns the instance with the given content.static IScriptofId(java.lang.String id)Returns the instance with the given id.static IScriptofSrc(java.lang.String src)Returns the instance with the given src.IScriptwithCharset(java.lang.String charset)Returns a copy ofthisimmutable component with the specifiedcharset.IScriptwithContent(java.lang.String content)Returns a copy ofthisimmutable component with the specifiedcontent.IScriptwithDefer(boolean defer)Returns a copy ofthisimmutable component with the specifieddefer.IScriptwithPackages(java.lang.String packages)Returns a copy ofthisimmutable component with the specifiedpackages.IScriptwithSrc(java.lang.String charset)Returns a copy ofthisimmutable component with the specifiedcharset.-
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:
getWidgetClassin interfaceIComponent<IScript>- Returns:
-
getCharset
@Nullable java.lang.String getCharset()
Returns the character encoding of the source. It is used withgetSrc().Default:
null.
-
withCharset
IScript withCharset(@Nullable java.lang.String charset)
Returns a copy ofthisimmutable component with the specifiedcharset.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
thisobject
-
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 ofthisimmutable component with the specifiedcharset.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
thisobject
-
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
thisreferences to this script widget.
-
withDefer
IScript withDefer(boolean defer)
Returns a copy ofthisimmutable component with the specifieddefer.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
thisobject
-
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 ofthisimmutable component with the specifiedcontent.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
thisobject
-
getPackages
@Nullable java.lang.String getPackages()
Returns the list of packages to load before evaluating the script defined ingetContent(). It is meaning only ifgetContent()not null.Default:
null.
-
withPackages
IScript withPackages(@Nullable java.lang.String packages)
Returns a copy ofthisimmutable component with the specifiedpackages.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
thisobject
-
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
-
-