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
ConstructorsConstructorDescriptionCreates 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 TypeMethodDescriptionvoidaddStyleClass(String styleClass, boolean force) Adds a CSS style class.protected intboxBorder(Orientation orientation) Returns the widget's built-in border width.protected intboxPadding(Orientation orientation) Returns the widget's built-in padding.voidcallJavaScriptMember(String name, String args) Calls a JavaScript member.voiddoJavaScript(String js) Executes the given JavaScript statements when the widget is rendered or updated.protected voidProgresses to an Ajax-enabled widget.Finds a descendent widget by name.Finds a descendent widget by id.getAttributeValue(String name) Returns an attribute value.intReturns 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 WWidgetGet 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.intReturns the margin around the viewport within which the widget is considered visible.Returns the CSS style class.intReturns the tab index.protected WWidgetReturns the tooltip.Returns the vertical alignment.Returns the fixed vertical alignment that was set.getWidth()Returns the width.booleanhasFocus()Returns whether the widget currently has the focus.booleanhasStyleClass(String styleClass) Returns whether the widget has a style class.booleanReturns whether the widget can receive focus.booleanReturns whether the widget is set disabled.booleanReturns whether the widget is enabled.booleanisHidden()Returns whether the widget is set hidden.booleanReturns whether the widget keeps its geometry when hidden.booleanisInline()Returns whether the widget is displayed inline or as block.booleanisLoaded()Returns whether this widget has been loaded.booleanisPopup()Returns whether the widget is overlayed.booleanReturns whether scroll visibility detection is enabled for this widget.booleanReturns whether this widget is currently considered scroll visible.booleanSet focus on the widget's first descendant.booleanReturns whether this widget is currently styled by the chosen theme.booleanReturns whether the widget is visible.voidload()Loads content just before the widget is used.voidpropagateSetEnabled(boolean enabled) Propagates that a widget was enabled or disabled through children.voidpropagateSetVisible(boolean visible) voidrefresh()Refresh the widget.voidremove()Destructor.voidremoveStyleClass(String styleClass, boolean force) Removes a CSS style class.removeWidget(WWidget child) Removes a child widget.protected voidrender(EnumSet<RenderFlag> flags) Renders the widget.voidResizes the widget.Signaltriggered when the scroll visibility of this widget changes.voidsetAttributeValue(String name, String value) Sets an attribute value.voidsetCanReceiveFocus(boolean enabled) Sets whether the widget can receive focus.voidsetClearSides(EnumSet<Side> sides) Sets the sides that should be cleared of floats.voidSets a CSS decoration style.voidsetDeferredToolTip(boolean enable, TextFormat textFormat) Enable deferred tooltip.voidsetDisabled(boolean disabled) Sets whether the widget is disabled.voidsetFloatSide(Side s) Specifies a CSS float side.voidsetFocus(boolean focus) Sets focus.voidsetHidden(boolean hidden, WAnimation animation) Hides or shows the widget.voidsetHiddenKeepsGeometry(boolean enabled) Sets whether the widget keeps its geometry when hidden.voidSets the CSS Id.protected voidsetImplementation(WWidget widget) Set the implementation widget.voidsetInline(boolean isInline) Sets whether the widget is displayed inline or as a block.voidsetJavaScriptMember(String name, String value) Sets a JavaScript member.voidsetLineHeight(WLength height) Sets the CSS line height for contained text.voidSets CSS margins around the widget.voidsetMaximumSize(WLength width, WLength height) Sets a maximum size.voidsetMinimumSize(WLength width, WLength height) Sets a minimum size.voidsetObjectName(String name) Sets an object name.voidsetOffsets(WLength offset, EnumSet<Side> sides) Sets CSS offsets for a non-statically positioned widget.protected voidsetParentWidget(WWidget parent) voidsetPopup(boolean popup) Lets the widget overlay over other sibling widgets.voidsetPositionScheme(PositionScheme scheme) Sets the CSS position scheme.voidsetScrollVisibilityEnabled(boolean enabled) Sets whether scroll visibility detection is enabled for this widget.voidsetScrollVisibilityMargin(int margin) Sets the margin around the viewport within which the widget is considered visible.voidsetSelectable(boolean selectable) Sets as selectable.voidsetStyleClass(String styleClass) Sets (one or more) CSS style classes.voidsetTabIndex(int index) Sets the tab index.voidsetThemeStyleEnabled(boolean enabled) Sets whether theme styling for a widget is enabled or disabled.voidsetToolTip(CharSequence text, TextFormat textFormat) Sets a tooltip.voidsetVerticalAlignment(AlignmentFlag alignment, WLength length) Sets the vertical alignment.Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, isRendered, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, trMethods 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:WWidgetDestructor.Deletes a widget and all contained contents.
-
getChildren
Description copied from class:WWidgetReturns child widgets.This returns widgets for which widget.
getParent()== this.- Specified by:
getChildrenin classWWidget
-
removeWidget
Description copied from class:WWidgetRemoves a child widget.- Overrides:
removeWidgetin classWWidget
-
setObjectName
Description copied from class:WObjectSets 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:
setObjectNamein classWObject- Parameters:
name- the object name.
-
getObjectName
Description copied from class:WObjectReturns the object name.- Overrides:
getObjectNamein classWObject- Returns:
- the object name.
-
getId
Description copied from class:WObjectReturns 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 aWCompositeWidgetshares 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:WWidgetSets 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:
setPositionSchemein classWWidget- See Also:
-
getPositionScheme
Description copied from class:WWidgetReturns the CSS position scheme.This applies to CSS-based layout.
- Specified by:
getPositionSchemein classWWidget- See Also:
-
setOffsets
Description copied from class:WWidgetSets CSS offsets for a non-statically positioned widget.The argument
sidesmay 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 positionedwidget, an offset applies relative to the position the widget would have when layed-out using astaticposition scheme. The widget may be shifted to the left or right by specifying an offset for theleftorright) side. The widget may be shifted vertically, by specifying an offset for thetoporbottomside.For an
absolutely positionedwidget, 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 positionedwidget, 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:
setOffsetsin classWWidget- See Also:
-
getOffset
Description copied from class:WWidgetReturns a CSS offset.This applies to CSS-based layout.
-
resize
Description copied from class:WWidgetResizes the widget.Specifies a fixed size for this widget, setting CSS
widthandheightproperties. 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 the 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:WWidgetReturns 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:WWidgetReturns 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:WWidgetSets a minimum size.Specifies a minimum size for this widget, setting CSS
min-widthandmin-heightproperties.The default minimum width and height is 0. The special value
WLength.Autoindicates that the initial width is used as minimum size. ALengthUnit.Percentagesize 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:
setMinimumSizein classWWidget- See Also:
-
getMinimumWidth
Description copied from class:WWidgetReturns the minimum width.Returns the minimum width set for this widget with
setMinimumSize().- Specified by:
getMinimumWidthin classWWidget- See Also:
-
getMinimumHeight
Description copied from class:WWidgetReturns the minimum height.Returns the minmum height set for this widget with
setMinimumSize().- Specified by:
getMinimumHeightin classWWidget- See Also:
-
setMaximumSize
Description copied from class:WWidgetSets a maximum size.Specifies a maximum size for this widget, setting CSS
max-widthandmax-heightproperties.The default the maximum width and height are
WLength.Auto, indicating no maximum size. ALengthUnit.Percentagesize 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:
setMaximumSizein classWWidget- See Also:
-
getMaximumWidth
Description copied from class:WWidgetReturns the maximum width.Returns the maximum width set for this widget with
setMaximumSize().- Specified by:
getMaximumWidthin classWWidget- See Also:
-
getMaximumHeight
Description copied from class:WWidgetReturns the maximum height.Returns the minmum height set for this widget with
setMaximumSize().- Specified by:
getMaximumHeightin classWWidget- See Also:
-
setLineHeight
Description copied from class:WWidgetSets the CSS line height for contained text.- Specified by:
setLineHeightin classWWidget
-
getLineHeight
Description copied from class:WWidgetReturns the CSS line height for contained text.- Specified by:
getLineHeightin classWWidget
-
setFloatSide
Description copied from class:WWidgetSpecifies a CSS float side.This only applies to widgets with a
PositionScheme.StaticgetPositionScheme().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:
setFloatSidein classWWidget
-
getFloatSide
Description copied from class:WWidgetReturns the CSS float side.- Specified by:
getFloatSidein classWWidget- See Also:
-
setClearSides
Description copied from class:WWidgetSets 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.LeftandSide.Right).This applies to CSS-based layout.
- Specified by:
setClearSidesin classWWidget- See Also:
-
getClearSides
Description copied from class:WWidgetReturns the sides that should remain empty.- Specified by:
getClearSidesin classWWidget- See Also:
-
setMargin
Description copied from class:WWidgetSets 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:WWidgetReturns a CSS margin set.This applies to CSS-based layout.
-
setHiddenKeepsGeometry
public void setHiddenKeepsGeometry(boolean enabled) Description copied from class:WWidgetSets 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:
setHiddenKeepsGeometryin classWWidget- See Also:
-
isHiddenKeepsGeometry
public boolean isHiddenKeepsGeometry()Description copied from class:WWidgetReturns whether the widget keeps its geometry when hidden.- Specified by:
isHiddenKeepsGeometryin classWWidget- See Also:
-
setHidden
Description copied from class:WWidgetHides 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:WWidgetReturns 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:WWidgetReturns 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:WWidgetSets whether the widget is disabled.The widget can be set to being disabled, or enabled. This state will also be propagated to all its descendants. Those descendants will only be "visually" made disabled, their actual
isDisabled()state will remain unaltered. All descendants will be assigned the disabled styleclass, which is dependent on the used Theme.The
isDisabled()check will thus only returntruein case setDisabled(true) has been called on the widget before. If the anscestor of a widget has been marked setDisabled(true), the widget'sisDisabled()state will remainfalse.To check if a widget has been passively disabled, by one of its anscestors, use
isEnabled().Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.
- Specified by:
setDisabledin classWWidget- See Also:
-
isDisabled
public boolean isDisabled()Description copied from class:WWidgetReturns whether the widget is set disabled.This method will return
trueif, and only if, it has been marked setDisabled(true) explicitly. It can still inherit the disabled state from one of its anscestors.- Specified by:
isDisabledin classWWidget- See Also:
-
isEnabled
public boolean isEnabled()Description copied from class:WWidgetReturns 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:WWidgetLets 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.AbsoluteorPositionScheme.FixedgetPositionScheme().This applies to CSS-based layout, and configures the z-index property.
-
isPopup
public boolean isPopup()Description copied from class:WWidgetReturns whether the widget is overlayed.This applies to CSS-based layout.
-
setInline
public void setInline(boolean isInline) Description copied from class:WWidgetSets 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:WWidgetReturns whether the widget is displayed inline or as block. -
setDecorationStyle
Description copied from class:WWidgetSets a CSS decoration style.This copies the style over its current
getDecorationStyle()- Specified by:
setDecorationStylein classWWidget
-
getDecorationStyle
Description copied from class:WWidgetReturns 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:
getDecorationStylein classWWidget- See Also:
-
setStyleClass
Description copied from class:WWidgetSets (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:
setStyleClassin classWWidget- See Also:
-
getStyleClass
Description copied from class:WWidgetReturns the CSS style class.- Specified by:
getStyleClassin classWWidget- See Also:
-
addStyleClass
Description copied from class:WWidgetAdds 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
styleClassshould 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:
addStyleClassin classWWidget
-
removeStyleClass
Description copied from class:WWidgetRemoves 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
styleClassshould be a single class- Specified by:
removeStyleClassin classWWidget
-
hasStyleClass
Description copied from class:WWidgetReturns whether the widget has a style class.- Specified by:
hasStyleClassin classWWidget
-
setVerticalAlignment
Description copied from class:WWidgetSets 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:
setVerticalAlignmentin classWWidget
-
getVerticalAlignment
Description copied from class:WWidgetReturns the vertical alignment.This applies to CSS-based layout.
- Specified by:
getVerticalAlignmentin classWWidget- See Also:
-
getVerticalAlignmentLength
Description copied from class:WWidgetReturns the fixed vertical alignment that was set.This applies to CSS-based layout.
- Specified by:
getVerticalAlignmentLengthin classWWidget- See Also:
-
setToolTip
Description copied from class:WWidgetSets a tooltip.The tooltip is displayed when the cursor hovers over the widget.
When
textFormatisTextFormat.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:
setToolTipin classWWidget
-
getToolTip
Description copied from class:WWidgetReturns the tooltip.- Specified by:
getToolTipin classWWidget
-
setDeferredToolTip
Description copied from class:WWidgetEnable deferred tooltip.You may override
getToolTip()to read data only when the user hovers over the widget.When
textFormatisTextFormat.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:
setDeferredToolTipin classWWidget- See Also:
-
refresh
public void refresh()Description copied from class:WWidgetRefresh 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:WWidgetSets 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:
setAttributeValuein classWWidget- See Also:
-
getAttributeValue
Description copied from class:WWidgetReturns an attribute value.- Specified by:
getAttributeValuein classWWidget- See Also:
-
setJavaScriptMember
Description copied from class:WWidgetSets 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:
setJavaScriptMemberin classWWidget
-
getJavaScriptMember
Description copied from class:WWidgetReturns the value of a JavaScript member.- Specified by:
getJavaScriptMemberin classWWidget- See Also:
-
callJavaScriptMember
Description copied from class:WWidgetCalls a JavaScript member.This calls a JavaScript member.
- Specified by:
callJavaScriptMemberin classWWidget- See Also:
-
load
public void load()Description copied from class:WWidgetLoads 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:WWidgetReturns whether this widget has been loaded. -
setCanReceiveFocus
public void setCanReceiveFocus(boolean enabled) Description copied from class:WWidgetSets 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:
setCanReceiveFocusin classWWidget
-
isCanReceiveFocus
public boolean isCanReceiveFocus()Description copied from class:WWidgetReturns whether the widget can receive focus.- Specified by:
isCanReceiveFocusin classWWidget- See Also:
-
setFocus
public void setFocus(boolean focus) Description copied from class:WWidgetSets focus.When using
focus=false, you can undo a previoussetFocus()call. -
isSetFirstFocus
public boolean isSetFirstFocus()Description copied from class:WWidgetSet 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:
isSetFirstFocusin classWWidget
-
hasFocus
public boolean hasFocus()Description copied from class:WWidgetReturns whether the widget currently has the focus. -
setTabIndex
public void setTabIndex(int index) Description copied from class:WWidgetSets 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:
setTabIndexin classWWidget
-
getTabIndex
public int getTabIndex()Description copied from class:WWidgetReturns the tab index.- Specified by:
getTabIndexin classWWidget- See Also:
-
setId
Description copied from class:WWidgetSets 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:WWidgetFinds a descendent widget by name. -
findById
Description copied from class:WWidgetFinds a descendent widget by id. -
setSelectable
public void setSelectable(boolean selectable) Description copied from class:WWidgetSets 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:
setSelectablein classWWidget
-
doJavaScript
Description copied from class:WWidgetExecutes 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:
doJavaScriptin classWWidget- See Also:
-
propagateSetEnabled
public void propagateSetEnabled(boolean enabled) Description copied from class:WWidgetPropagates 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:
propagateSetEnabledin classWWidget
-
propagateSetVisible
public void propagateSetVisible(boolean visible) - Specified by:
propagateSetVisiblein classWWidget
-
isScrollVisibilityEnabled
public boolean isScrollVisibilityEnabled()Description copied from class:WWidgetReturns whether scroll visibility detection is enabled for this widget.- Specified by:
isScrollVisibilityEnabledin classWWidget- See Also:
-
setScrollVisibilityEnabled
public void setScrollVisibilityEnabled(boolean enabled) Description copied from class:WWidgetSets 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
scrollvisibilityexample.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:
setScrollVisibilityEnabledin classWWidget
-
getScrollVisibilityMargin
public int getScrollVisibilityMargin()Description copied from class:WWidgetReturns the margin around the viewport within which the widget is considered visible.- Specified by:
getScrollVisibilityMarginin classWWidget- See Also:
-
setScrollVisibilityMargin
public void setScrollVisibilityMargin(int margin) Description copied from class:WWidgetSets 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:
setScrollVisibilityMarginin classWWidget
-
scrollVisibilityChanged
Description copied from class:WWidgetSignaltriggered when the scroll visibility of this widget changes.The boolean parameter indicates whether the widget is currently scroll visible.
- Specified by:
scrollVisibilityChangedin classWWidget- See Also:
-
isScrollVisible
public boolean isScrollVisible()Description copied from class:WWidgetReturns whether this widget is currently considered scroll visible.isScrollVisible()is initially false.- Specified by:
isScrollVisiblein classWWidget- See Also:
-
setThemeStyleEnabled
public void setThemeStyleEnabled(boolean enabled) Description copied from class:WWidgetSets 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.
This function does, however, not always completely remove every style class added by JWt, as some of those are needed in order for the widget to function correctly. Additionally, Bootstrap 5 makes some changes to the default style of some widgets in the browser, like with buttons. These changes are not removed by this function.
Note: This should be changed after the construction but before the rendering of the widget or before the call to
applyThemeStyles()(depending on what happens first).- Specified by:
setThemeStyleEnabledin classWWidget
-
isThemeStyleEnabled
public boolean isThemeStyleEnabled()Description copied from class:WWidgetReturns whether this widget is currently styled by the chosen theme.isThemeEnabled() is initially true.
- Specified by:
isThemeStyleEnabledin classWWidget- See Also:
-
getBaseZIndex
public int getBaseZIndex()- Specified by:
getBaseZIndexin classWWidget
-
enableAjax
protected void enableAjax()Description copied from class:WWidgetProgresses 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:
enableAjaxin 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:WWidgetReturns 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:
boxPaddingin classWWidget- See Also:
-
boxBorder
Description copied from class:WWidgetReturns 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:WWidgetRenders 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.
-
setParentWidget
-