Class WCompositeWidget

Direct Known Subclasses:
WAbstractItemView, WCalendar, WDatePicker, WGoogleMap, WIconPair, WInPlaceEdit, WLeafletMap, WLoadingIndicator, WMediaPlayer, WMenu, WPanel, WPopupWidget, WSplitButton, WTabWidget, WToolBar, WTree, WTreeNode, WTreeTable, WVirtualImage

public class WCompositeWidget extends WWidget
A widget that hides the implementation of composite widgets.

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.

  • Constructor Details

  • Method Details

    • remove

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

      Deletes a widget and all contained contents.

      Overrides:
      remove in class WWidget
      See Also:
    • getChildren

      public List<WWidget> getChildren()
      Description copied from class: WWidget
      Returns child widgets.

      This returns widgets for which widget.getParent() == this.

      Specified by:
      getChildren in class WWidget
    • removeWidget

      public WWidget removeWidget(WWidget child)
      Description copied from class: WWidget
      Removes a child widget.
      Overrides:
      removeWidget in class WWidget
    • setObjectName

      public void setObjectName(String name)
      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 class WObject
      Parameters:
      name - the object name.
    • getObjectName

      public String getObjectName()
      Description copied from class: WObject
      Returns the object name.
      Overrides:
      getObjectName in class WObject
      Returns:
      the object name.
    • getId

      public 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
    • 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 PositionScheme.Static.

      This applies to CSS-based layout.

      Specified by:
      setPositionScheme in class WWidget
      See Also:
    • 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:
    • setOffsets

      public void setOffsets(WLength offset, 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:
    • 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:
    • resize

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

      Specifies a fixed size for this widget, setting CSS width and height 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.

      Overrides:
      resize in class WWidget
      See Also:
    • 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:
    • 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:
    • setMinimumSize

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

      Specifies a minimum size for this widget, setting CSS min-width and min-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. A LengthUnit.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 class WWidget
      See Also:
    • 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:
    • 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:
    • setMaximumSize

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

      Specifies a maximum size for this widget, setting CSS max-width and max-height properties.

      The default the maximum width and height are WLength.Auto, indicating no maximum size. A LengthUnit.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 class WWidget
      See Also:
    • 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:
    • 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:
    • 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 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:
    • setClearSides

      public void setClearSides(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:
    • getClearSides

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

      Specified by:
      getClearSides in class WWidget
      See Also:
    • setMargin

      public void setMargin(WLength margin, 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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, 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:
    • 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:
    • setStyleClass

      public void setStyleClass(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:
    • getStyleClass

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

      Specified by:
      getStyleClass in class WWidget
      See Also:
    • addStyleClass

      public void addStyleClass(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.

      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 class WWidget
    • removeStyleClass

      public void removeStyleClass(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.

      The styleClass should be a single class

      Specified by:
      removeStyleClass in class WWidget
    • hasStyleClass

      public boolean hasStyleClass(String styleClass)
      Description copied from class: WWidget
      Returns whether the widget has a style class.
      Specified by:
      hasStyleClass 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:
    • 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:
    • setToolTip

      public void setToolTip(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 TextFormat.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 class WWidget
    • getToolTip

      public WString getToolTip()
      Description copied from class: WWidget
      Returns the tooltip.
      Specified by:
      getToolTip in class WWidget
    • setDeferredToolTip

      public void setDeferredToolTip(boolean enable, TextFormat textFormat)
      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 is TextFormat.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 class WWidget
      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 reimplemented refresh() to attach to it an effect).

      Overrides:
      refresh in class WWidget
    • setAttributeValue

      public void setAttributeValue(String name, String value)
      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 class WWidget
      See Also:
    • getAttributeValue

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

      Specified by:
      getAttributeValue in class WWidget
      See Also:
    • setJavaScriptMember

      public void setJavaScriptMember(String name, 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 String getJavaScriptMember(String name)
      Description copied from class: WWidget
      Returns the value of a JavaScript member.

      Specified by:
      getJavaScriptMember in class WWidget
      See Also:
    • callJavaScriptMember

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

      This calls a JavaScript member.

      Specified by:
      callJavaScriptMember in class WWidget
      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.

      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:
    • 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 class WWidget
    • isCanReceiveFocus

      public boolean isCanReceiveFocus()
      Description copied from class: WWidget
      Returns whether the widget can receive focus.

      Specified by:
      isCanReceiveFocus in class WWidget
      See Also:
    • setFocus

      public void setFocus(boolean focus)
      Description copied from class: WWidget
      Sets focus.

      When using focus = false, you can undo a previous setFocus() call.

      Specified by:
      setFocus in class WWidget
    • 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 class WWidget
    • hasFocus

      public boolean hasFocus()
      Description copied from class: WWidget
      Returns whether the widget currently has the focus.
      Specified by:
      hasFocus in class WWidget
    • 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 class WWidget
    • getTabIndex

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

      Specified by:
      getTabIndex in class WWidget
      See Also:
    • setId

      public void setId(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.

      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()).

      Specified by:
      setId in class WWidget
      See Also:
    • find

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

      Specified by:
      find in class WWidget
      See Also:
    • findById

      public WWidget findById(String id)
      Description copied from class: WWidget
      Finds a descendent widget by id.
      Specified by:
      findById in class WWidget
    • 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(String js)
      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:
    • 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 class WWidget
    • propagateSetVisible

      public void propagateSetVisible(boolean visible)
      Specified by:
      propagateSetVisible in class WWidget
    • isScrollVisibilityEnabled

      public boolean isScrollVisibilityEnabled()
      Description copied from class: WWidget
      Returns whether scroll visibility detection is enabled for this widget.

      Specified by:
      isScrollVisibilityEnabled in class WWidget
      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 by getScrollVisibilityMargin().

      If scroll visibility changes, the scrollVisibilityChanged() signal is fired, and isScrollVisible() 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, the scrollVisibilityChanged() signal will not be emitted.

      Note: If scroll visibility is enabled, disabled, and then enabled again, isScrollVisible() may not be correctly updated, and scrollVisibilityChanged() 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 class WWidget
    • 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 class WWidget
      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 class WWidget
    • scrollVisibilityChanged

      public Signal1<Boolean> 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 class WWidget
      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 class WWidget
      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 class WWidget
    • 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 class WWidget
      See Also:
    • getBaseZIndex

      public int getBaseZIndex()
      Specified by:
      getBaseZIndex 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:
    • setImplementation

      protected void setImplementation(WWidget widget)
      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

      protected WWidget getImplementation()
      Get the implementation widget.

      This returns the widget that implements this compositeWidget.

    • getTakeImplementation

      protected WWidget getTakeImplementation()
    • boxPadding

      protected int boxPadding(Orientation orientation)
      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 class WWidget
      See Also:
    • boxBorder

      protected int boxBorder(Orientation orientation)
      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.

      Overrides:
      boxBorder in class WWidget
      See Also:
    • render

      protected void render(EnumSet<RenderFlag> flags)
      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.

      Overrides:
      render in class WWidget