Class WCompositeWidget
- Direct Known Subclasses:
WAbstractItemView
,WCalendar
,WDatePicker
,WGoogleMap
,WIconPair
,WInPlaceEdit
,WLeafletMap
,WLoadingIndicator
,WMediaPlayer
,WMenu
,WPanel
,WPopupWidget
,WSplitButton
,WTabWidget
,WToolBar
,WTree
,WTreeNode
,WTreeTable
,WVirtualImage
Composite widgets, built on top of the WebWidgets, should derive from this class, and use
setImplementation()
to set the widget
that implements the composite widget (which is typically a WContainerWidget
or a WTable
, or another widget that allows composition, including perhaps another WCompositeWidget).
Using this class you can completely hide the implementation of your composite widget, and
provide access to only the standard WWidget
methods.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Constructor Summary
ConstructorDescriptionCreates a WCompositeWidget.WCompositeWidget
(WContainerWidget parentContainer) Creates a WCompositeWidget.WCompositeWidget
(WWidget implementation) Creates a WCompositeWidget with given implementation.WCompositeWidget
(WWidget implementation, WContainerWidget parentContainer) Creates a WCompositeWidget with given implementation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStyleClass
(String styleClass, boolean force) Adds a CSS style class.protected int
boxBorder
(Orientation orientation) Returns the widget's built-in border width.protected int
boxPadding
(Orientation orientation) Returns the widget's built-in padding.void
callJavaScriptMember
(String name, String args) Calls a JavaScript member.void
doJavaScript
(String js) Executes the given JavaScript statements when the widget is rendered or updated.protected void
Progresses to an Ajax-enabled widget.Finds a descendent widget by name.Finds a descendent widget by id.getAttributeValue
(String name) Returns an attribute value.int
Returns child widgets.Returns the sides that should remain empty.Returns the decoration style of this widget.Returns the CSS float side.Returns the height.getId()
Returns the (unique) identifier for this objectprotected WWidget
Get the implementation widget.getJavaScriptMember
(String name) Returns the value of a JavaScript member.Returns the CSS line height for contained text.Returns a CSS margin set.Returns the maximum height.Returns the maximum width.Returns the minimum height.Returns the minimum width.Returns the object name.Returns a CSS offset.Returns the CSS position scheme.int
Returns the margin around the viewport within which the widget is considered visible.Returns the CSS style class.int
Returns the tab index.protected WWidget
Returns the tooltip.Returns the vertical alignment.Returns the fixed vertical alignment that was set.getWidth()
Returns the width.boolean
hasFocus()
Returns whether the widget currently has the focus.boolean
hasStyleClass
(String styleClass) Returns whether the widget has a style class.boolean
Returns whether the widget can receive focus.boolean
Returns whether the widget is set disabled.boolean
Returns whether the widget is enabled.boolean
isHidden()
Returns whether the widget is set hidden.boolean
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
Returns whether scroll visibility detection is enabled for this widget.boolean
Returns whether this widget is currently considered scroll visible.boolean
Set focus on the widget's first descendant.boolean
Returns whether this widget is currently styled by the chosen theme.boolean
Returns whether the widget is visible.void
load()
Loads content just before the widget is used.void
propagateSetEnabled
(boolean enabled) Propagates that a widget was enabled or disabled through children.void
propagateSetVisible
(boolean visible) void
refresh()
Refresh the widget.void
remove()
Destructor.void
removeStyleClass
(String styleClass, boolean force) Removes a CSS style class.removeWidget
(WWidget child) Removes a child widget.protected void
render
(EnumSet<RenderFlag> flags) Renders the widget.void
Resizes the widget.Signal
triggered when the scroll visibility of this widget changes.void
setAttributeValue
(String name, String value) Sets an attribute value.void
setCanReceiveFocus
(boolean enabled) Sets whether the widget can receive focus.void
setClearSides
(EnumSet<Side> sides) Sets the sides that should be cleared of floats.void
Sets a CSS decoration style.void
setDeferredToolTip
(boolean enable, TextFormat textFormat) Enable deferred tooltip.void
setDisabled
(boolean disabled) Sets whether the widget is disabled.void
setFloatSide
(Side s) Specifies a CSS float side.void
setFocus
(boolean focus) Sets focus.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
Sets the CSS Id.protected void
setImplementation
(WWidget widget) Set the implementation widget.void
setInline
(boolean isInline) Sets whether the widget is displayed inline or as a block.void
setJavaScriptMember
(String name, String value) Sets a JavaScript member.void
setLineHeight
(WLength height) Sets the CSS line height for contained text.void
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
setObjectName
(String name) Sets an object name.void
setOffsets
(WLength offset, 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
setScrollVisibilityEnabled
(boolean enabled) Sets whether scroll visibility detection is enabled for this widget.void
setScrollVisibilityMargin
(int margin) Sets the margin around the viewport within which the widget is considered visible.void
setSelectable
(boolean selectable) Sets as selectable.void
setStyleClass
(String styleClass) Sets (one or more) CSS style classes.void
setTabIndex
(int index) Sets the tab index.void
setThemeStyleEnabled
(boolean enabled) Sets whether theme styling for a widget is enabled or disabled.void
setToolTip
(CharSequence text, TextFormat textFormat) Sets a tooltip.void
setVerticalAlignment
(AlignmentFlag alignment, WLength length) Sets the vertical alignment.Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, 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
setFormData
-
Constructor Details
-
WCompositeWidget
Creates a WCompositeWidget.You need to set an implemetation using
setImplementation()
directly after construction. -
WCompositeWidget
public WCompositeWidget()Creates a WCompositeWidget. -
WCompositeWidget
Creates a WCompositeWidget with given implementation.- See Also:
-
WCompositeWidget
Creates a WCompositeWidget with given implementation.
-
-
Method Details
-
remove
public void remove()Description copied from class:WWidget
Destructor.Deletes a widget and all contained contents.
-
getChildren
Description copied from class:WWidget
Returns child widgets.This returns widgets for which widget.
getParent()
== this.- Specified by:
getChildren
in classWWidget
-
removeWidget
Description copied from class:WWidget
Removes a child widget.- Overrides:
removeWidget
in classWWidget
-
setObjectName
Description copied from class:WObject
Sets an object name.The object name can be used to easily identify a type of object in the DOM, and does not need to be unique. It will usually reflect the widget type or role. The object name is prepended to the auto-generated object
WObject.getId()
.The default object name is empty.
- Overrides:
setObjectName
in classWObject
- Parameters:
name
- the object name.
-
getObjectName
Description copied from class:WObject
Returns the object name.- Overrides:
getObjectName
in classWObject
- Returns:
- the object name.
-
getId
Description copied from class:WObject
Returns the (unique) identifier for this objectFor a
WWidget
, this corresponds to the id of the DOM element that represents the widget. This is not entirely unique, since aWCompositeWidget
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 concatenatingWObject.getObjectName()
with a unique number. -
setPositionScheme
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
PositionScheme.Static
.This applies to CSS-based layout.
- Specified by:
setPositionScheme
in classWWidget
- See Also:
-
getPositionScheme
Description copied from class:WWidget
Returns the CSS position scheme.This applies to CSS-based layout.
- Specified by:
getPositionScheme
in classWWidget
- See Also:
-
setOffsets
Description copied from class:WWidget
Sets CSS offsets for a non-statically positioned widget.The argument
sides
may be a combination ofSide.Left
,Side.Right
,Side.Top
, andSide.Bottom
.This applies only to widgets that have a position scheme that is
PositionScheme.Relative
,PositionScheme.Absolute
, orPositionScheme.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 astatic
position scheme. The widget may be shifted to the left or right by specifying an offset for theleft
orright
) side. The widget may be shifted vertically, by specifying an offset for thetop
orbottom
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 classWWidget
- See Also:
-
getOffset
Description copied from class:WWidget
Returns a CSS offset.This applies to CSS-based layout.
-
resize
Description copied from class:WWidget
Resizes the widget.Specifies a fixed size for this widget, setting CSS
width
andheight
properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:
- a block widget takes by default the width of the parent, and the height that it needs based on its contents
- an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).
When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using
setLayoutSizeAware()
. If you have defined a"wtResize()"
JavaScript method for the widget, then this method will also be called.The default width and height of a widget is
WLength.Auto
. -
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.
-
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.
-
setMinimumSize
Description copied from class:WWidget
Sets a minimum size.Specifies a minimum size for this widget, setting CSS
min-width
andmin-height
properties.The default minimum width and height is 0. The special value
WLength.Auto
indicates that the initial width is used as minimum size. ALengthUnit.Percentage
size should not be used, as this is (in virtually all cases) undefined behaviour.When the widget is inserted in a layout manager, then the minimum size will be taken into account.
- Specified by:
setMinimumSize
in classWWidget
- See Also:
-
getMinimumWidth
Description copied from class:WWidget
Returns the minimum width.Returns the minimum width set for this widget with
setMinimumSize()
.- Specified by:
getMinimumWidth
in classWWidget
- See Also:
-
getMinimumHeight
Description copied from class:WWidget
Returns the minimum height.Returns the minmum height set for this widget with
setMinimumSize()
.- Specified by:
getMinimumHeight
in classWWidget
- See Also:
-
setMaximumSize
Description copied from class:WWidget
Sets a maximum size.Specifies a maximum size for this widget, setting CSS
max-width
andmax-height
properties.The default the maximum width and height are
WLength.Auto
, indicating no maximum size. ALengthUnit.Percentage
size should not be used, as this is (in virtually all cases) undefined behaviour.When the widget is a container widget that contains a layout manager, then setting a maximum size will have the effect of letting the size of the container to reflect the preferred size of the contents (rather than constraining the size of the children based on the size of the container), up to the specified maximum size.
- Specified by:
setMaximumSize
in classWWidget
- See Also:
-
getMaximumWidth
Description copied from class:WWidget
Returns the maximum width.Returns the maximum width set for this widget with
setMaximumSize()
.- Specified by:
getMaximumWidth
in classWWidget
- See Also:
-
getMaximumHeight
Description copied from class:WWidget
Returns the maximum height.Returns the minmum height set for this widget with
setMaximumSize()
.- Specified by:
getMaximumHeight
in classWWidget
- See Also:
-
setLineHeight
Description copied from class:WWidget
Sets the CSS line height for contained text.- Specified by:
setLineHeight
in classWWidget
-
getLineHeight
Description copied from class:WWidget
Returns the CSS line height for contained text.- Specified by:
getLineHeight
in classWWidget
-
setFloatSide
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
Side.Left
, orSide.Right
.This applies to CSS-based layout.
- Specified by:
setFloatSide
in classWWidget
-
getFloatSide
Description copied from class:WWidget
Returns the CSS float side.- Specified by:
getFloatSide
in classWWidget
- See Also:
-
setClearSides
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 ofSide.Left
andSide.Right
).This applies to CSS-based layout.
- Specified by:
setClearSides
in classWWidget
- See Also:
-
getClearSides
Description copied from class:WWidget
Returns the sides that should remain empty.- Specified by:
getClearSides
in classWWidget
- See Also:
-
setMargin
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
, orSide.Top
.This applies to CSS-based layout.
-
getMargin
Description copied from class:WWidget
Returns a CSS margin set.This applies to CSS-based layout.
-
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 classWWidget
- See Also:
-
isHiddenKeepsGeometry
public boolean isHiddenKeepsGeometry()Description copied from class:WWidget
Returns whether the widget keeps its geometry when hidden.- Specified by:
isHiddenKeepsGeometry
in classWWidget
- See Also:
-
setHidden
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 usingisVisible()
. -
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. -
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.
-
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 classWWidget
- See Also:
-
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 classWWidget
- See Also:
-
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.
-
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
orPositionScheme.Fixed
getPositionScheme()
.This applies to CSS-based layout, and configures the z-index property.
-
isPopup
public boolean isPopup()Description copied from class:WWidget
Returns whether the widget is overlayed.This applies to CSS-based layout.
-
setInline
public void setInline(boolean isInline) 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
, orWPushButton
), or block (such as for example for aWContainerWidget
).This applies to CSS-based layout.
-
isInline
public boolean isInline()Description copied from class:WWidget
Returns whether the widget is displayed inline or as block. -
setDecorationStyle
Description copied from class:WWidget
Sets a CSS decoration style.This copies the style over its current
getDecorationStyle()
- Specified by:
setDecorationStyle
in classWWidget
-
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 classWWidget
- See Also:
-
setStyleClass
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 classWWidget
- See Also:
-
getStyleClass
Description copied from class:WWidget
Returns the CSS style class.- Specified by:
getStyleClass
in classWWidget
- See Also:
-
addStyleClass
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.The
styleClass
should be a single class (although multiple classes will work for the common case that the additional style classes are all not yet present on the element.- Specified by:
addStyleClass
in classWWidget
-
removeStyleClass
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.The
styleClass
should be a single class- Specified by:
removeStyleClass
in classWWidget
-
hasStyleClass
Description copied from class:WWidget
Returns whether the widget has a style class.- Specified by:
hasStyleClass
in classWWidget
-
setVerticalAlignment
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 classWWidget
-
getVerticalAlignment
Description copied from class:WWidget
Returns the vertical alignment.This applies to CSS-based layout.
- Specified by:
getVerticalAlignment
in classWWidget
- See Also:
-
getVerticalAlignmentLength
Description copied from class:WWidget
Returns the fixed vertical alignment that was set.This applies to CSS-based layout.
- Specified by:
getVerticalAlignmentLength
in classWWidget
- See Also:
-
setToolTip
Description copied from class:WWidget
Sets a tooltip.The tooltip is displayed when the cursor hovers over the widget.
When
textFormat
isTextFormat.XHTML
, the tooltip may contain any valid XHTML snippet. The tooltip will then be rendered using JavaScript.Note: This will set deferred tooltip to false.
- Specified by:
setToolTip
in classWWidget
-
getToolTip
Description copied from class:WWidget
Returns the tooltip.- Specified by:
getToolTip
in classWWidget
-
setDeferredToolTip
Description copied from class:WWidget
Enable deferred tooltip.You may override
getToolTip()
to read data only when the user hovers over the widget.When
textFormat
isTextFormat.XHTML
, the tooltip may contain any valid XHTML snippet. The tooltip will then be rendered using JavaScript.Note: To change existing toolTip call
setDeferredToolTip()
again.- Specified by:
setDeferredToolTip
in classWWidget
- See Also:
-
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.
Note: This does not rerender the widget! Calling
refresh()
usually does not have any effect (unless you've reimplementedrefresh()
to attach to it an effect). -
setAttributeValue
Description copied from class:WWidget
Sets an attribute value.Sets the value for an HTML attribute.
This is only useful for HTML features that are not supported directly in JWt (and beware that browsers have non-consistent support for many more exotic HTML features).
- Specified by:
setAttributeValue
in classWWidget
- See Also:
-
getAttributeValue
Description copied from class:WWidget
Returns an attribute value.- Specified by:
getAttributeValue
in classWWidget
- See Also:
-
setJavaScriptMember
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 doingresize()
to set the size of the widget, instead of setting the CSS width and height properties.- Specified by:
setJavaScriptMember
in classWWidget
-
getJavaScriptMember
Description copied from class:WWidget
Returns the value of a JavaScript member.- Specified by:
getJavaScriptMember
in classWWidget
- See Also:
-
callJavaScriptMember
Description copied from class:WWidget
Calls a JavaScript member.This calls a JavaScript member.
- Specified by:
callJavaScriptMember
in classWWidget
- See Also:
-
load
public void load()Description copied from class:WWidget
Loads content just before the widget is used.This function is called when a widget is inserted in the widget hierarchy. 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 initialization only once.
-
isLoaded
public boolean isLoaded()Description copied from class:WWidget
Returns whether this widget has been loaded. -
setCanReceiveFocus
public void setCanReceiveFocus(boolean enabled) Description copied from class:WWidget
Sets whether the widget can receive focus.By default, only form widgets (descendants of
WFormWidget
), anchors (WAnchor
) and buttons (WPushButton
) can receive focus.Any other widget can be configured to receive focus however.
- Specified by:
setCanReceiveFocus
in classWWidget
-
isCanReceiveFocus
public boolean isCanReceiveFocus()Description copied from class:WWidget
Returns whether the widget can receive focus.- Specified by:
isCanReceiveFocus
in classWWidget
- See Also:
-
setFocus
public void setFocus(boolean focus) Description copied from class:WWidget
Sets focus.When using
focus
=false
, you can undo a previoussetFocus()
call. -
isSetFirstFocus
public boolean isSetFirstFocus()Description copied from class:WWidget
Set focus on the widget's first descendant.Set focus on the widget itself, or on a first descendant which can receive focus.
Returns whether focus could be set.
- Specified by:
isSetFirstFocus
in classWWidget
-
hasFocus
public boolean hasFocus()Description copied from class:WWidget
Returns whether the widget currently has the focus. -
setTabIndex
public void setTabIndex(int index) Description copied from class:WWidget
Sets the tab index.For widgets that receive focus (
isCanReceiveFocus()
), 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.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 (for a widget that can receive focus).
- Specified by:
setTabIndex
in classWWidget
-
getTabIndex
public int getTabIndex()Description copied from class:WWidget
Returns the tab index.- Specified by:
getTabIndex
in classWWidget
- See Also:
-
setId
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.
Note: An id must start with a letter ([A-Za-z]), followed by one or more letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
Warning: We recommend that you leave the id of a widget unchanged. JWt uses the id to identify widgets in the JavaScript it generates, and this can often leads to bugs. If you do change the id, only change the id right after widget construction. However, usually there's a more preferable alternative, like setting the object name (
WObject#setObjectName()
), or adding style classes (addStyleClass()
). -
find
Description copied from class:WWidget
Finds a descendent widget by name. -
findById
Description copied from class:WWidget
Finds a descendent widget by id. -
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 classWWidget
-
doJavaScript
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 usinggetJsRef()
, 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 classWWidget
- See Also:
-
propagateSetEnabled
public 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 classWWidget
-
propagateSetVisible
public void propagateSetVisible(boolean visible) - Specified by:
propagateSetVisible
in classWWidget
-
isScrollVisibilityEnabled
public boolean isScrollVisibilityEnabled()Description copied from class:WWidget
Returns whether scroll visibility detection is enabled for this widget.- Specified by:
isScrollVisibilityEnabled
in classWWidget
- See Also:
-
setScrollVisibilityEnabled
public void setScrollVisibilityEnabled(boolean enabled) Description copied from class:WWidget
Sets whether scroll visibility detection is enabled for this widget.Disabled by default. When enabled, the client keeps track of whether this widget is currently visible inside of the browser window. A widget is "scroll visible" if it is currently visible according to
isVisible()
, and its position is inside of the browser window, with an extra margin determined bygetScrollVisibilityMargin()
.If scroll visibility changes, the
scrollVisibilityChanged()
signal is fired, andisScrollVisible()
is updated.This feature can be useful to implement infinite scroll, where a sentinel widget placed at the bottom of the page causes more content to be loaded when it becomes visible, see the
scrollvisibility
example.This feature can also be used to lazy load widgets when they become visible.
Note: If the widget is "scroll visible" when scroll visibility detection is first enabled, the
scrollVisibilityChanged()
signal will be emitted. If it is outside of the browser's viewport when first enabled, thescrollVisibilityChanged()
signal will not be emitted.Note: If scroll visibility is enabled, disabled, and then enabled again,
isScrollVisible()
may not be correctly updated, andscrollVisibilityChanged()
may not be correctly emitted, because then JWt can't properly keep track of the state that the widget is in on the client side. This feature is not intended to be toggled on and off, but rather enabled once and disabled once after that.- Specified by:
setScrollVisibilityEnabled
in classWWidget
-
getScrollVisibilityMargin
public int getScrollVisibilityMargin()Description copied from class:WWidget
Returns the margin around the viewport within which the widget is considered visible.- Specified by:
getScrollVisibilityMargin
in classWWidget
- See Also:
-
setScrollVisibilityMargin
public void setScrollVisibilityMargin(int margin) Description copied from class:WWidget
Sets the margin around the viewport within which the widget is considered visible.This causes the widget to be considered "scroll visible" before it is within the viewport. Setting this margin could be useful to trigger the loading of content before it is in view.
- Specified by:
setScrollVisibilityMargin
in classWWidget
-
scrollVisibilityChanged
Description copied from class:WWidget
Signal
triggered when the scroll visibility of this widget changes.The boolean parameter indicates whether the widget is currently scroll visible.
- Specified by:
scrollVisibilityChanged
in classWWidget
- See Also:
-
isScrollVisible
public boolean isScrollVisible()Description copied from class:WWidget
Returns whether this widget is currently considered scroll visible.isScrollVisible()
is initially false.- Specified by:
isScrollVisible
in classWWidget
- See Also:
-
setThemeStyleEnabled
public void setThemeStyleEnabled(boolean enabled) Description copied from class:WWidget
Sets whether theme styling for a widget is enabled or disabled.By default all widgets are styled according to the chosen theme. Disabling the theme style could be useful to completely customize the style of the widget outside of the theme.
Note: This should be changed after the construction but before the rendering of the widget.
- Specified by:
setThemeStyleEnabled
in classWWidget
-
isThemeStyleEnabled
public boolean isThemeStyleEnabled()Description copied from class:WWidget
Returns whether this widget is currently styled by the chosen theme.isThemeEnabled() is initially true.
- Specified by:
isThemeStyleEnabled
in classWWidget
- See Also:
-
getBaseZIndex
public int getBaseZIndex()- Specified by:
getBaseZIndex
in classWWidget
-
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 classWWidget
- See Also:
-
setImplementation
Set the implementation widget.This sets the widget that implements this compositeWidget. Ownership of the widget is completely transferred (including deletion).
Note: You cannot change the implementation of a composite widget after it has been rendered.
-
getImplementation
Get the implementation widget.This returns the widget that implements this compositeWidget.
-
getTakeImplementation
-
boxPadding
Description copied from class:WWidget
Returns the widget's built-in padding.This is used by the layout managers to correct for a built-in padding which interferes with setting a widget's width (or height) to 100%.
A layout manager needs to set the width to 100% only for form widgets (
WTextArea
,WLineEdit
,WComboBox
, etc...). Therefore, only for those widgets this needs to return the padding (the default implementation returns 0).For form widgets, the padding depends on the specific browser/platform combination, unless an explicit padding is set for the widget.
When setting an explicit padding for the widget using a style class, you will want to reimplement this method to return this padding in case you want to set the widget inside a layout manager.
- Overrides:
boxPadding
in classWWidget
- See Also:
-
boxBorder
Description copied from class:WWidget
Returns the widget's built-in border width.This is used by the layout managers to correct for a built-in border which interferes with setting a widget's width (or height) to 100%.
A layout manager needs to set the width to 100% only for form widgets (
WTextArea
,WLineEdit
,WComboBox
, etc...). Therefore, only for those widgets this needs to return the border width (the default implementation returns 0).For form widgets, the border width depends on the specific browser/platform combination, unless an explicit border is set for the widget.
When setting an explicit border for the widget using a style class, you will want to reimplement this method to return this border width, in case you want to set the widget inside a layout manager.
-
render
Description copied from class:WWidget
Renders the widget.This function renders the widget (or an update for the widget), after this has been scheduled using
scheduleRender()
.The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
-