eu.webtoolkit.jwt
Class WWebWidget

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
Direct Known Subclasses:
WBreak, WFileUpload, WFlashObject, WInteractWidget, WScrollArea, WViewWidget

public abstract class WWebWidget
extends WWidget

A base class for widgets with an HTML counterpart.

All descendants of WWebWidget implement a widget which corresponds almost one-on-one with an HTML element. These widgets provide most capabilities of these HTML elements, but rarely make no attempt to do anything more.

See Also:
WCompositeWidget

Constructor Summary
WWebWidget()
          Construct a WebWidget with a given parent.
WWebWidget(WContainerWidget parent)
          Construct a WebWidget with a given parent.
 
Method Summary
 void addStyleClass(java.lang.String styleClass, boolean force)
          Adds a CSS style class.
 void callJavaScriptMember(java.lang.String name, java.lang.String args)
          Calls a JavaScript member.
 Signal childrenChanged()
          Signal emitted when children have been added or removed.
 void doJavaScript(java.lang.String javascript)
          Executes the given JavaScript statements when the widget is rendered or updated.
protected  boolean domCanBeSaved()
           
protected  void enableAjax()
          Progresses to an Ajax-enabled widget.
static WString escapeText(java.lang.CharSequence text)
          Escape HTML control characters in the text, to display literally.
static WString escapeText(java.lang.CharSequence text, boolean newlinestoo)
          Escape HTML control characters in the text, to display literally.
static java.lang.String escapeText(java.lang.String text)
          Escape HTML control characters in the text, to display literally.
static java.lang.String escapeText(java.lang.String text, boolean newlinestoo)
          Escape HTML control characters in the text, to display literally.
 WWidget find(java.lang.String name)
          Finds a descendent widget by name.
 java.lang.String getAttributeValue(java.lang.String name)
          Returns an attribute value.
 java.util.List<WWidget> getChildren()
          Returns contained widgets.
 java.util.EnumSet<Side> getClearSides()
          Returns the sides that should remain empty.
 WCssDecorationStyle getDecorationStyle()
          Returns the decoration style of this widget.
 Side getFloatSide()
          Returns the CSS float side.
 WLength getHeight()
          Returns the height.
 java.lang.String getId()
          Returns the (unique) identifier for this object
 java.lang.String getJavaScriptMember(java.lang.String name)
          Returns the value of a JavaScript member.
 WLength getLineHeight()
          Returns the CSS line height for contained text.
 WLength getMargin(Side side)
          Returns a CSS margin set.
 WLength getMaximumHeight()
          Returns the maximum height.
 WLength getMaximumWidth()
          Returns the maximum width.
 WLength getMinimumHeight()
          Returns the minimum height.
 WLength getMinimumWidth()
          Returns the minimum width.
 WLength getOffset(Side s)
          Returns a CSS offset.
 PositionScheme getPositionScheme()
          Returns the CSS position scheme.
 java.lang.String getStyleClass()
          Returns the CSS style class.
 int getTabIndex()
          Returns the tab index.
 WString getToolTip()
          Returns the tooltip.
 AlignmentFlag getVerticalAlignment()
          Returns the vertical alignment.
 WLength getVerticalAlignmentLength()
          Returns the fixed vertical alignment that was set.
 WLength getWidth()
          Returns the width.
 boolean isDisabled()
          Returns whether the widget is set disabled.
 boolean isEnabled()
          Returns whether the widget is enabled.
 boolean isHidden()
          Returns whether the widget is set hidden.
 boolean isHiddenKeepsGeometry()
          Returns whether the widget keeps its geometry when hidden.
 boolean isInline()
          Returns whether the widget is displayed inline or as block.
 boolean isLoaded()
          Returns whether this widget has been loaded.
 boolean isPopup()
          Returns whether the widget is overlayed.
 boolean isRendered()
          Returns whether the widget is rendered.
 boolean isVisible()
          Returns whether the widget is visible.
static java.lang.String jsStringLiteral(java.lang.String value)
          Turn a UTF8 encoded string into a JavaScript string literal.
static java.lang.String jsStringLiteral(java.lang.String value, char delimiter)
          Turn a UTF8 encoded string into a JavaScript string literal.
 void load()
          Loads content just before the widget is used.
protected  void propagateSetEnabled(boolean enabled)
          Propagates that a widget was enabled or disabled through children.
 void refresh()
          Refresh the widget.
 void remove()
          Destructor.
static boolean removeScript(java.lang.CharSequence text)
          Remove tags/attributes from text that are not passive.
 void removeStyleClass(java.lang.String styleClass, boolean force)
          Removes a CSS style class.
 void resize(WLength width, WLength height)
          Resizes the widget.
 void setAttributeValue(java.lang.String name, java.lang.String value)
          Sets an attribute value.
 void setClearSides(java.util.EnumSet<Side> sides)
          Sets the sides that should be cleared of floats.
 void setDecorationStyle(WCssDecorationStyle style)
          Sets a CSS decoration style.
 void setDisabled(boolean disabled)
          Sets whether the widget is disabled.
 void setFloatSide(Side s)
          Specifies a CSS float side.
 void setHidden(boolean hidden, WAnimation animation)
          Hides or shows the widget.
 void setHiddenKeepsGeometry(boolean enabled)
          Sets whether the widget keeps its geometry when hidden.
 void setId(java.lang.String id)
          Sets the CSS Id.
 void setInline(boolean inl)
          Sets whether the widget is displayed inline or as a block.
 void setJavaScriptMember(java.lang.String name, java.lang.String value)
          Sets a JavaScript member.
 void setLineHeight(WLength height)
          Sets the CSS line height for contained text.
 void setLoadLaterWhenInvisible(boolean how)
          Change the way the widget is loaded when invisible.
 void setMargin(WLength margin, java.util.EnumSet<Side> sides)
          Sets CSS margins around the widget.
 void setMaximumSize(WLength width, WLength height)
          Sets a maximum size.
 void setMinimumSize(WLength width, WLength height)
          Sets a minimum size.
 void setOffsets(WLength offset, java.util.EnumSet<Side> sides)
          Sets CSS offsets for a non-statically positioned widget.
 void setPopup(boolean popup)
          Lets the widget overlay over other sibling widgets.
 void setPositionScheme(PositionScheme scheme)
          Sets the CSS position scheme.
 void setSelectable(boolean selectable)
          Sets as selectable.
 void setStyleClass(java.lang.String styleClass)
          Sets (one or more) CSS style classes.
 void setTabIndex(int index)
          Sets the tab index.
 void setToolTip(java.lang.CharSequence text, TextFormat textFormat)
          Sets a tooltip.
 void setVerticalAlignment(AlignmentFlag alignment, WLength length)
          Sets the vertical alignment.
protected  void updateSignalConnection(eu.webtoolkit.jwt.DomElement element, AbstractEventSignal signal, java.lang.String name, boolean all)
           
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WWebWidget

public WWebWidget(WContainerWidget parent)
Construct a WebWidget with a given parent.

See Also:
WWidget.WWidget(WContainerWidget parent)

WWebWidget

public WWebWidget()
Construct a WebWidget with a given parent.

Calls this((WContainerWidget)null)

Method Detail

remove

public void remove()
Description copied from class: WWidget
Destructor.

Deletes a widget and all children (recursively). If the widget is contained in another widget, it is removed first.

Overrides:
remove in class WWidget
See Also:
WContainerWidget.removeWidget(WWidget widget)

setPositionScheme

public void setPositionScheme(PositionScheme scheme)
Description copied from class: WWidget
Sets the CSS position scheme.

Establishes how the widget must be layed-out relative to its siblings. The default position scheme is Static.

This applies to CSS-based layout.

Specified by:
setPositionScheme in class WWidget
See Also:
PositionScheme, WWidget.getPositionScheme()

getPositionScheme

public PositionScheme getPositionScheme()
Description copied from class: WWidget
Returns the CSS position scheme.

This applies to CSS-based layout.

Specified by:
getPositionScheme in class WWidget
See Also:
PositionScheme, WWidget.setPositionScheme(PositionScheme scheme)

setOffsets

public void setOffsets(WLength offset,
                       java.util.EnumSet<Side> sides)
Description copied from class: WWidget
Sets CSS offsets for a non-statically positioned widget.

The argument sides may be a combination of Side.Left, Side.Right, Side.Top, and Side.Bottom.

This applies only to widgets that have a position scheme that is PositionScheme.Relative, PositionScheme.Absolute, or PositionScheme.Fixed, and has a slightly different meaning for these three cases.

For a relatively positioned widget, an offset applies relative to the position the widget would have when layed-out using a static position scheme. The widget may be shifted to the left or right by specifying an offset for the left or right) side. The widget may be shifted vertically, by specifying an offset for the top or bottom side.

For an absolutely positioned widget, an offset specifies a distance of the corresponding side of the widget with respect to the corresponding side of the reference parent widget. Thus, setting all offsets to 0 result in a widget that spans the entire reference widget. The reference parent widget is the first ancestor widget that is a table cell, or a widget with a relative, absolute or fixed position scheme.

For an fixed positioned widget, an offset specifies a distance of the corresponding side of the widget with respect to the browser window, regardless of scrolling. Thus, setting all offsets to 0 result in a widget that spans the entire browser window.

This applies to CSS-based layout.

Specified by:
setOffsets in class WWidget
See Also:
WWidget.getOffset(Side side)

getOffset

public WLength getOffset(Side s)
Description copied from class: WWidget
Returns a CSS offset.

This applies to CSS-based layout.

Specified by:
getOffset in class WWidget
See Also:
WWidget.setOffsets(WLength offset, EnumSet sides)

resize

public void resize(WLength width,
                   WLength height)
Description copied from class: WWidget
Resizes the widget.

Specify a new size for this widget, by specifying width and height. By default a widget has automatic width and height, see WLength#isAuto().

This applies to CSS-based layout, and only block widgets can be given a size reliably.

When inserted in a layout manager, the widget may be informed about its current size using setLayoutSizeAware(). If you have defined a "wtResize()" JavaScript method for the widget, then this method will also be called. operation.

Overrides:
resize in class WWidget
See Also:
WWidget.getWidth(), WWidget.getHeight()

getWidth

public WLength getWidth()
Description copied from class: WWidget
Returns the width.

Returns the width set for this widget. This is not a calculated width, based on layout, but the width as specified with resize().

This applies to CSS-based layout.

Specified by:
getWidth in class WWidget
See Also:
WWidget.resize(WLength width, WLength height), WWidget.getHeight()

getHeight

public WLength getHeight()
Description copied from class: WWidget
Returns the height.

Returns the height set for this widget. This is not a calculated height, based on layout, but the height as specified previously with resize().

This applies to CSS-based layout.

Specified by:
getHeight in class WWidget
See Also:
WWidget.resize(WLength width, WLength height), WWidget.getWidth()

setMinimumSize

public void setMinimumSize(WLength width,
                           WLength height)
Description copied from class: WWidget
Sets a minimum size.

Specify a minimum size for this widget.

The default minimum width and height is 0. The special value WLength.Auto indicates that the initial width is used as minimum size.

When the widget size is actively managed (using e.g. a layout manager), these sizes are taken into account.

Specified by:
setMinimumSize in class WWidget
See Also:
WWidget.resize(WLength width, WLength height), WWidget.getMinimumWidth(), WWidget.getMinimumHeight()

getMinimumWidth

public WLength getMinimumWidth()
Description copied from class: WWidget
Returns the minimum width.

Returns the minimum width set for this widget with setMinimumSize().

Specified by:
getMinimumWidth in class WWidget
See Also:
WWidget.setMinimumSize(WLength width, WLength height), WWidget.getMinimumHeight()

getMinimumHeight

public WLength getMinimumHeight()
Description copied from class: WWidget
Returns the minimum height.

Returns the minmum height set for this widget with setMinimumSize().

Specified by:
getMinimumHeight in class WWidget
See Also:
WWidget.setMinimumSize(WLength width, WLength height), WWidget.getMinimumWidth()

setMaximumSize

public void setMaximumSize(WLength width,
                           WLength height)
Description copied from class: WWidget
Sets a maximum size.

Specifies a maximum size for this widget.

The default maximum width and height are WLength.Auto, indicating no maximum size.

Specified by:
setMaximumSize in class WWidget
See Also:
WWidget.resize(WLength width, WLength height), WWidget.setMinimumSize(WLength width, WLength height)

getMaximumWidth

public WLength getMaximumWidth()
Description copied from class: WWidget
Returns the maximum width.

Returns the maximum width set for this widget with setMaximumSize().

Specified by:
getMaximumWidth in class WWidget
See Also:
WWidget.setMaximumSize(WLength width, WLength height), WWidget.getMaximumHeight()

getMaximumHeight

public WLength getMaximumHeight()
Description copied from class: WWidget
Returns the maximum height.

Returns the minmum height set for this widget with setMaximumSize().

Specified by:
getMaximumHeight in class WWidget
See Also:
WWidget.setMaximumSize(WLength width, WLength height), WWidget.getMaximumWidth()

setLineHeight

public void setLineHeight(WLength height)
Description copied from class: WWidget
Sets the CSS line height for contained text.

Specified by:
setLineHeight in class WWidget

getLineHeight

public WLength getLineHeight()
Description copied from class: WWidget
Returns the CSS line height for contained text.

sa setLineHeight()

Specified by:
getLineHeight in class WWidget

setFloatSide

public void setFloatSide(Side s)
Description copied from class: WWidget
Specifies a CSS float side.

This only applies to widgets with a PositionScheme.Static getPositionScheme().

This lets the widget float to one of the sides of the parent widget, at the current line. A typical use is to position images within text. Valid values for Side or java None , Side.Left or Side.Right.

This applies to CSS-based layout.

Specified by:
setFloatSide in class WWidget

getFloatSide

public Side getFloatSide()
Description copied from class: WWidget
Returns the CSS float side.

Specified by:
getFloatSide in class WWidget
See Also:
WWidget.setFloatSide(Side s)

setClearSides

public void setClearSides(java.util.EnumSet<Side> sides)
Description copied from class: WWidget
Sets the sides that should be cleared of floats.

This pushes the widget down until it is not surrounded by floats at the sides (which may be a combination of Side.Left and Side.Right).

This applies to CSS-based layout.

Specified by:
setClearSides in class WWidget
See Also:
WWidget.setFloatSide(Side s)

getClearSides

public java.util.EnumSet<Side> getClearSides()
Description copied from class: WWidget
Returns the sides that should remain empty.

Specified by:
getClearSides in class WWidget
See Also:
WWidget.setClearSides(EnumSet sides)

setMargin

public void setMargin(WLength margin,
                      java.util.EnumSet<Side> sides)
Description copied from class: WWidget
Sets CSS margins around the widget.

Setting margin has the effect of adding a distance between the widget and surrounding widgets. The default margin (with an automatic length) is zero.

Use any combination of Side.Left, Side.Right, Side.Bottom, or Side.Top.

This applies to CSS-based layout.

Specified by:
setMargin in class WWidget
See Also:
WWidget.getMargin(Side side)

getMargin

public WLength getMargin(Side side)
Description copied from class: WWidget
Returns a CSS margin set.

This applies to CSS-based layout.

Specified by:
getMargin in class WWidget
See Also:
WWidget.setMargin(WLength margin, EnumSet sides)

setHiddenKeepsGeometry

public void setHiddenKeepsGeometry(boolean enabled)
Description copied from class: WWidget
Sets whether the widget keeps its geometry when hidden.

Normally, a widget that is hidden will no longer occupy space, causing a reflow of sibling widgets. Using this method you may change this behavior to keep an (open) space when hidden.

Note: Currently you can only set this before initial rendering.

Specified by:
setHiddenKeepsGeometry in class WWidget
See Also:
WWidget.setHidden(boolean hidden, WAnimation animation)

isHiddenKeepsGeometry

public boolean isHiddenKeepsGeometry()
Description copied from class: WWidget
Returns whether the widget keeps its geometry when hidden.

Specified by:
isHiddenKeepsGeometry in class WWidget
See Also:
WWidget.setHiddenKeepsGeometry(boolean enabled)

setHidden

public void setHidden(boolean hidden,
                      WAnimation animation)
Description copied from class: WWidget
Hides or shows the widget.

Hides or show the widget (including all its descendant widgets). When setting hidden = false, this widget and all descendant widgets that are not hidden will be shown. A widget is only visible if it and all its ancestors in the widget tree are visible, which may be checked using isVisible().

Specified by:
setHidden in class WWidget

isHidden

public boolean isHidden()
Description copied from class: WWidget
Returns whether the widget is set hidden.

A widget that is not hidden may still be not visible when one of its ancestor widgets is hidden. Use isVisible() to check the visibility of a widget.

Specified by:
isHidden in class WWidget
See Also:
WWidget.setHidden(boolean hidden, WAnimation animation), WWidget.isVisible()

isVisible

public boolean isVisible()
Description copied from class: WWidget
Returns whether the widget is visible.

A widget is visible if it is not hidden, and none of its ancestors are hidden. This method returns the true visibility, while isHidden() returns whether a widget has been explicitly hidden.

Note that a widget may be at the same time not hidden, and not visible, in case one of its ancestors was hidden.

Specified by:
isVisible in class WWidget
See Also:
WWidget.isHidden()

setDisabled

public void setDisabled(boolean disabled)
Description copied from class: WWidget
Sets whether the widget is disabled.

Enables or disables the widget (including all its descendant widgets). setDisabled(false) will enable this widget and all descendant widgets that are not disabled. A widget is only enabled if it and all its ancestors in the widget tree are disabled.

Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.

Specified by:
setDisabled in class WWidget
See Also:
WWidget.disable(), WWidget.enable()

isDisabled

public boolean isDisabled()
Description copied from class: WWidget
Returns whether the widget is set disabled.

A widget that is not set disabled may still be disabled when one of its ancestor widgets is set disabled. Use isEnabled() to find out whether a widget is enabled.

Specified by:
isDisabled in class WWidget
See Also:
WWidget.setDisabled(boolean disabled), WWidget.isEnabled()

isEnabled

public boolean isEnabled()
Description copied from class: WWidget
Returns whether the widget is enabled.

A widget is enabled if it is not disabled, and none of its ancestors are disabled. This method returns whether the widget is rendered as enabled, while isDisabled() returns whether a widget has been explicitly disabled.

Note that a widget may be at the same time not enabled, and not disabled, in case one of its ancestors was disabled.

Specified by:
isEnabled in class WWidget
See Also:
WWidget.isDisabled()

setPopup

public void setPopup(boolean popup)
Description copied from class: WWidget
Lets the widget overlay over other sibling widgets.

A widget that isPopup() will be rendered on top of any other sibling widget contained within the same parent (including other popup widgets previously added to the container).

This will only have an effect when the widgetis either PositionScheme.Absolute or PositionScheme.Fixed getPositionScheme().

This applies to CSS-based layout, and configures the z-index property.

Specified by:
setPopup in class WWidget

isPopup

public boolean isPopup()
Description copied from class: WWidget
Returns whether the widget is overlayed.

This applies to CSS-based layout.

Specified by:
isPopup in class WWidget
See Also:
WWidget.setPopup(boolean popup)

setInline

public void setInline(boolean inl)
Description copied from class: WWidget
Sets whether the widget is displayed inline or as a block.

This option changes whether this widget must be rendered in line with sibling widgets wrapping at the right edge of the parent container (like text), or whether this widget must be rendered as a rectangular block that stacks vertically with sibling widgets (unless a CSS float property is applied). Depending on the widget type, the default value is inline (such as for example for WText, or WPushButton), or block (such as for example for a WContainerWidget).

This applies to CSS-based layout.

Specified by:
setInline in class WWidget

isInline

public boolean isInline()
Description copied from class: WWidget
Returns whether the widget is displayed inline or as block.

Specified by:
isInline in class WWidget
See Also:
WWidget.setInline(boolean inlined)

setDecorationStyle

public void setDecorationStyle(WCssDecorationStyle style)
Description copied from class: WWidget
Sets a CSS decoration style.

This copies the style over its current getDecorationStyle()

Specified by:
setDecorationStyle in class WWidget

getDecorationStyle

public WCssDecorationStyle getDecorationStyle()
Description copied from class: WWidget
Returns the decoration style of this widget.

This groups all decorative aspects of the widget, which do not affect the widget layout (except for the border properties which may behave like extra margin around the widget).

When a decoration style has not been previously set, it returns a default decoration style object.

Specified by:
getDecorationStyle in class WWidget
See Also:
WWidget.setDecorationStyle(WCssDecorationStyle style)

setStyleClass

public void setStyleClass(java.lang.String styleClass)
Description copied from class: WWidget
Sets (one or more) CSS style classes.

You may set one or more space separated style classes. CSS style class works in conjunction with style sheet, and provides a flexible way to provide many widgets the same markup.

Setting an empty string removes the style class(es).

Specified by:
setStyleClass in class WWidget
See Also:
WApplication.getStyleSheet()

getStyleClass

public java.lang.String getStyleClass()
Description copied from class: WWidget
Returns the CSS style class.

Specified by:
getStyleClass in class WWidget
See Also:
WWidget.setStyleClass(String styleClass)

addStyleClass

public void addStyleClass(java.lang.String styleClass,
                          boolean force)
Description copied from class: WWidget
Adds a CSS style class.

When force = true, a JavaScript call will be used to add the style class to the DOM element (if JavaScript is available). This may be necessary when client-side JavaScript manipulates the same style class.

Specified by:
addStyleClass in class WWidget

removeStyleClass

public void removeStyleClass(java.lang.String styleClass,
                             boolean force)
Description copied from class: WWidget
Removes a CSS style class.

When force = true, a JavaScript call will be used to remove the style class from the DOM element (if JavaScript is available). This may be necessary when client-side JavaScript manipulates the same style class.

Specified by:
removeStyleClass in class WWidget

setVerticalAlignment

public void setVerticalAlignment(AlignmentFlag alignment,
                                 WLength length)
Description copied from class: WWidget
Sets the vertical alignment.

This only applies to inline widgets, and determines how to position itself on the current line, with respect to sibling inline widgets.

This applies to CSS-based layout.

Specified by:
setVerticalAlignment in class WWidget

getVerticalAlignment

public AlignmentFlag getVerticalAlignment()
Description copied from class: WWidget
Returns the vertical alignment.

This applies to CSS-based layout.

Specified by:
getVerticalAlignment in class WWidget
See Also:
WWidget.setVerticalAlignment(AlignmentFlag alignment, WLength length)

getVerticalAlignmentLength

public WLength getVerticalAlignmentLength()
Description copied from class: WWidget
Returns the fixed vertical alignment that was set.

This applies to CSS-based layout.

Specified by:
getVerticalAlignmentLength in class WWidget
See Also:
WWidget.setVerticalAlignment(AlignmentFlag alignment, WLength length)

setToolTip

public void setToolTip(java.lang.CharSequence text,
                       TextFormat textFormat)
Description copied from class: WWidget
Sets a tooltip.

The tooltip is displayed when the cursor hovers over the widget.

When textFormat is XHTMLText, the tooltip may contain any valid XHTML snippet. The tooltip will then be rendered using JavaScript.

Specified by:
setToolTip in class WWidget

getToolTip

public WString getToolTip()
Description copied from class: WWidget
Returns the tooltip.

Specified by:
getToolTip in class WWidget

refresh

public void refresh()
Description copied from class: WWidget
Refresh the widget.

The refresh method is invoked when the locale is changed using WApplication#setLocale() or when the user hit the refresh button.

The widget must actualize its contents in response.

Overrides:
refresh in class WWidget

setAttributeValue

public void setAttributeValue(java.lang.String name,
                              java.lang.String value)
Description copied from class: WWidget
Sets an attribute value.

Associate an extra attribute with this widget, with the given value. This is only useful when processing dom nodes associated with widgets in custom JavaScript code.

Specified by:
setAttributeValue in class WWidget
See Also:
JSlot, WWidget.doJavaScript(String js)

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String name)
Description copied from class: WWidget
Returns an attribute value.

Specified by:
getAttributeValue in class WWidget
See Also:
WWidget.setAttributeValue(String name, String value)

setJavaScriptMember

public void setJavaScriptMember(java.lang.String name,
                                java.lang.String value)
Description copied from class: WWidget
Sets a JavaScript member.

This binds a JavaScript member, which is set as a JavaScript property to the DOM object that implements this widget. The value may be any JavaScript expression, including a function.

Members that start with "wt" are reserved for internal use. You may define a member "wtResize(self, width, height)" method if your widget needs active layout management. If defined, this method will be used by layout managers and when doing resize() to set the size of the widget, instead of setting the CSS width and height properties.

Specified by:
setJavaScriptMember in class WWidget

getJavaScriptMember

public java.lang.String getJavaScriptMember(java.lang.String name)
Description copied from class: WWidget
Returns the value of a JavaScript member.

Specified by:
getJavaScriptMember in class WWidget
See Also:
WWidget.setJavaScriptMember(String name, String value)

callJavaScriptMember

public void callJavaScriptMember(java.lang.String name,
                                 java.lang.String args)
Description copied from class: WWidget
Calls a JavaScript member.

This calls a JavaScript member.

Specified by:
callJavaScriptMember in class WWidget
See Also:
WWidget.setJavaScriptMember(String name, String value)

load

public void load()
Description copied from class: WWidget
Loads content just before the widget is used.

When the widget is inserted in the widget hierarchy, this method is called. Widgets that get inserted in the widget hierarchy will be rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground (or not for a plain HTML session). This method is called when the widget is directly or indirectly inserted into the widget tree.

The default implementation simply propagates the load signal to its children. You may want to override this method to delay loading of resource-intensive contents.

During the life-time of a widget, this method may be called multiple times, so you should make sure that you do a deferred initializiation only once.

Specified by:
load in class WWidget

isLoaded

public boolean isLoaded()
Description copied from class: WWidget
Returns whether this widget has been loaded.

Specified by:
isLoaded in class WWidget
See Also:
WWidget.load()

setTabIndex

public void setTabIndex(int index)
Description copied from class: WWidget
Sets the tab index.

For widgets that receive focus, focus is passed on to the next widget in the tabbing chain based on their tab index. When the user navigates through form widgets using the keyboard, widgets receive focus starting from the element with the lowest tab index to elements with the highest tab index.

A tab index only applies to widgets than can receive focus (which are WFormWidget, WAnchor, WPushButton), but setting a tab index on any other type of widget will propagate to its contained form widgets.

Widgets with a same tab index will receive focus in the same order as they are inserted in the widget tree.

The default tab index is 0.

Specified by:
setTabIndex in class WWidget

getTabIndex

public int getTabIndex()
Description copied from class: WWidget
Returns the tab index.

Specified by:
getTabIndex in class WWidget
See Also:
WWidget.setTabIndex(int index)

setId

public void setId(java.lang.String id)
Description copied from class: WWidget
Sets the CSS Id.

Sets a custom Id. Note that the Id must be unique across the whole widget tree, can only be set right after construction and cannot be changed. This is mostly useful for in tests using a test plan that manipulates DOM elements by Id.

By default, auto-generated id's are used.

Specified by:
setId in class WWidget
See Also:
WObject.getId()

find

public WWidget find(java.lang.String name)
Description copied from class: WWidget
Finds a descendent widget by name.

Specified by:
find in class WWidget
See Also:
WObject.setObjectName(String name)

setSelectable

public void setSelectable(boolean selectable)
Description copied from class: WWidget
Sets as selectable.

When a widget is made unselectable, a selection of text (or images) will not be visible (but may still be possible).

By default, the widget inherits this property from its parent, and this property propagates to all children. The top level container ( WApplication#getRoot()) selectable by default.

Specified by:
setSelectable in class WWidget

doJavaScript

public void doJavaScript(java.lang.String javascript)
Description copied from class: WWidget
Executes the given JavaScript statements when the widget is rendered or updated.

Calling WApplication#doJavaScript() with JavaScript code that refers to a widget using getJsRef(), that is still to be rendered may cause JavaScript errors because the corresponding DOM node does not exist. This happens for example when a widget is created, but not yet inserted in the widget tree.

This method guarantees that the JavaScript code is only run when the corresponding DOM node (using getJsRef()) resolves to a valid DOM object.

Specified by:
doJavaScript in class WWidget
See Also:
WWidget.getJsRef()

getId

public java.lang.String getId()
Description copied from class: WObject
Returns the (unique) identifier for this object

For a WWidget, this corresponds to the id of the DOM element that represents the widget. This is not entirely unique, since a WCompositeWidget shares the same id as its implementation.

By default, the id is auto-generated, unless a custom id is set for a widget using WWidget.setId(String). The auto-generated id is created by concatenating WObject.getObjectName() with a unique number.

Overrides:
getId in class WObject

setLoadLaterWhenInvisible

public void setLoadLaterWhenInvisible(boolean how)
Change the way the widget is loaded when invisible.

By default, invisible widgets are loaded only after visible content. For tiny widgets this may lead to a performance loss, instead of the expected increase, because they require many more DOM manipulations to render, reducing the overall responsiveness of the application.

Therefore, this is disabled for some widgets like WImage, or empty WContainerWidgets.

You may also want to disable deferred loading when JavaScript event handling expects the widget to be loaded.

Usually the default settings are fine, but you may want to change the behaviour.

See Also:
WApplication.setTwoPhaseRenderingThreshold(int bytes)

escapeText

public static WString escapeText(java.lang.CharSequence text,
                                 boolean newlinestoo)
Escape HTML control characters in the text, to display literally.


escapeText

public static final WString escapeText(java.lang.CharSequence text)
Escape HTML control characters in the text, to display literally.

Returns escapeText(text, false)


escapeText

public static java.lang.String escapeText(java.lang.String text,
                                          boolean newlinestoo)
Escape HTML control characters in the text, to display literally.


escapeText

public static final java.lang.String escapeText(java.lang.String text)
Escape HTML control characters in the text, to display literally.

Returns escapeText(text, false)


removeScript

public static boolean removeScript(java.lang.CharSequence text)
Remove tags/attributes from text that are not passive.

This removes tags and attributes from XHTML-formatted text that do not simply display something but may trigger scripting, and could have been injected by a malicious user for Cross-Site Scripting (XSS).

This method is used by the library to sanitize XHTML-formatted text set in WText, but it may also be useful outside the library to sanitize user content when direcly using JavaScript.

Modifies the text if needed. When the text is not proper XML, returns false.


jsStringLiteral

public static java.lang.String jsStringLiteral(java.lang.String value,
                                               char delimiter)
Turn a UTF8 encoded string into a JavaScript string literal.

The delimiter may be a single or double quote.


jsStringLiteral

public static final java.lang.String jsStringLiteral(java.lang.String value)
Turn a UTF8 encoded string into a JavaScript string literal.

Returns jsStringLiteral(value, '\'')


getChildren

public java.util.List<WWidget> getChildren()
Returns contained widgets.

See Also:
WContainerWidget.addWidget(WWidget widget)

childrenChanged

public Signal childrenChanged()
Signal emitted when children have been added or removed.

See Also:
getChildren()

isRendered

public boolean isRendered()
Description copied from class: WWidget
Returns whether the widget is rendered.

Overrides:
isRendered in class WWidget
See Also:
WWidget.getJsRef()

domCanBeSaved

protected boolean domCanBeSaved()

propagateSetEnabled

protected void propagateSetEnabled(boolean enabled)
Description copied from class: WWidget
Propagates that a widget was enabled or disabled through children.

When enabling or disabling a widget, you usually also want to disable contained children. This method is called by setDisabled() to propagate its state to all children.

You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.

Specified by:
propagateSetEnabled in class WWidget

enableAjax

protected void enableAjax()
Description copied from class: WWidget
Progresses to an Ajax-enabled widget.

This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.

You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.

Specified by:
enableAjax in class WWidget
See Also:
WApplication.enableAjax()

updateSignalConnection

protected void updateSignalConnection(eu.webtoolkit.jwt.DomElement element,
                                      AbstractEventSignal signal,
                                      java.lang.String name,
                                      boolean all)