public interface UIJavaScriptWriter
The JavaScript added with these methods is pure JavaScript. It is not necessary
to specify the script tag (<script>
).
For an HTML document, the JavaScript is stored in a special container at the end of the document, to be executed when required.
The JavaScript is executed once the whole page is loaded, by
the proprietary JavaScript code of EBX®.
There is no need to set on-load functions
(such as window.onload = myFunctionToCallOnload;
), because
the execution context is after the on-load event.
It is possible to instantly manage the HTML elements written with
UIBodyWriter.add(String)
.
Using the command document.write("some HTML");
is not recommended,
because the HTML will be written to the end of the document, namely before the closing
BODY tag </body>
, and not within an HTML section added with
UIBodyWriter.add(String)
.
A static JavaScript Catalog JavaScriptCatalog
is available,
to use with copy-paste in addJS(String)
or directly in JavaScript files.
JavaScriptCatalog
Modifier and Type | Method and Description |
---|---|
UIJavaScriptWriter |
addJS_addResizeWorkspaceListener(String aFunctionName)
Adds a JavaScript function to listen for workspace resizing.
|
UIJavaScriptWriter |
addJS_cr()
Adds a carriage return to the JavaScript stream.
|
UIJavaScriptWriter |
addJS_cr(String aJavaScriptCode)
Adds some text, then adds a carriage return to the JavaScript stream.
|
UIJavaScriptWriter |
addJS_openPreviewImage(String imageURL)
Opens an image preview panel for the given image URL.
|
UIJavaScriptWriter |
addJS_openPreviewImageFromVar(String varName)
Opens an image preview panel from a JavaScript
var containing the image URL. |
UIJavaScriptWriter |
addJS_setButtonDisabled(String buttonElement,
String isDisabled)
Disables or enables a button.
|
UIJavaScriptWriter |
addJS_setExpandCollapseBlockExpanded(String expandCollapseBlockId,
String isExpanded)
Expands or collapses an
expand/collapse block.
|
UIJavaScriptWriter |
addJS_setStateToToggleButton(String buttonElement,
String state)
Sets the state of a toggle button.
|
UIJavaScriptWriter |
addJS_switchToPerspective(String aPerspectiveName)
Changes the page of the highest EBX® frame to the specified perspective.
|
UIJavaScriptWriter |
addJS_switchToPerspectiveAction(String aPerspectiveName,
String aPerspectiveActionName)
Changes the page of the highest EBX® frame to the specified perspective action.
|
UIJavaScriptWriter |
addJS(String aJavaScriptCode)
Adds some text to the JavaScript stream.
|
UIJavaScriptWriter addJS(String aJavaScriptCode)
aJavaScriptCode
- JavaScript code.UIJavaScriptWriter addJS_cr()
UIJavaScriptWriter addJS_cr(String aJavaScriptCode)
aJavaScriptCode
- JavaScript code.UIJavaScriptWriter addJS_openPreviewImage(String imageURL)
imageURL
- the URL of the image. Supported extensions: BMP, GIF, JPEG, JPG, PNG, SWF.addJS_openPreviewImageFromVar(String)
UIJavaScriptWriter addJS_openPreviewImageFromVar(String varName)
var
containing the image URL.varName
- the name of the var
containing the URL of the image.
Supported extensions: BMP, GIF, JPEG, JPG, PNG, SWF.addJS_openPreviewImage(String)
UIJavaScriptWriter addJS_setButtonDisabled(String buttonElement, String isDisabled)
Buttons can be initially disabled with the method UIButtonSpec.setDisabled(boolean)
.
buttonElement
- a JavaScript expression evaluating to a button HTML Element.isDisabled
- a JavaScript expression evaluating to a Boolean.UIJavaScriptWriter addJS_setExpandCollapseBlockExpanded(String expandCollapseBlockId, String isExpanded)
The id of the expand/collapse block is given by the method
UIComponentWriter.startExpandCollapseBlock(UserMessage, boolean)
.
expandCollapseBlockId
- a JavaScript expression evaluating to an expand/collapse block id.isExpanded
- a JavaScript expression evaluating to a Boolean.UIJavaScriptWriter addJS_setStateToToggleButton(String buttonElement, String state)
The JavaScript commands will not be executed.
buttonElement
- a JavaScript expression evaluating to a button HTML Element.state
- a JavaScript expression evaluating to a Boolean (true for "ON" and false for "OFF").UIJavaScriptWriter addJS_addResizeWorkspaceListener(String aFunctionName)
The JavaScript function will be called at the end of the page loading and each time the workspace is resized.
Two JavaScript Objects
parameters are given to the JavaScript function.
The first Object
parameter contains three fields:
h
: the height of the workspace content region,
not including tab titles and not including the bottom bar;w
: the width of the workspace content region;vScroll
(since 5.9.0): the width of the vertical
scroll if it is present, or 0 if there is no scrollbar.
The second Object
parameter has been introduced in 5.9.0,
since the workspace displays a translucent form bottom bar in the workspace.
The goal is to let the developer choose the zone where the widget will
be displayed. It contains four fields:
h
: the height of the workspace content region,
not including tab titles;w
: the width of the workspace content region;vScroll
: the width of the vertical scroll
if it is present, or 0 if there is no scrollbar;hScroll
: the height of the horizontal scroll
if it is present, or 0 if there is no scrollbar.
Please note that isPaddingEnabled()
from UIFormPane
,
UserServicePane
and
UserServiceRawPane
are taken into account.
aFunctionName
- a JavaScript function name, which will be called when the workspace is resized.UIJavaScriptWriter addJS_switchToPerspective(String aPerspectiveName)
aPerspectiveName
- the name of the perspective,
or null
to have the advanced perspective.UIJavaScriptWriter addJS_switchToPerspectiveAction(String aPerspectiveName, String aPerspectiveActionName)
aPerspectiveName
- the name of the perspective,
or null
to have the advanced perspective.aPerspectiveActionName
- the name of the perspective action,
or null
to have the default action.