Class WObject

java.lang.Object
eu.webtoolkit.jwt.WObject
Direct Known Subclasses:
Login, OAuthAuthorizationEndpointProcess, OAuthProcess, WAbstractArea, WAbstractChartModel, WAbstractColorMap, WAbstractDataSeries3D, WAbstractItemDelegate, WAbstractItemModel, WApplication, WButtonGroup, WCanvasPaintDevice, WCssDecorationStyle, WCssRule, WDataSeries, WFileDropWidget.File, WFormModel, WItemSelectionModel, WLayout, WResource, WScrollBar, WServerGLWidget, WSound, WTableColumn, WTableRow, WTheme, WTimer, WValidator, WWidget

public class WObject
extends java.lang.Object
A simple base class for many JWt classes.

The class provides unique string IDs, which may be made identifiable using setObjectName(String).

The class also provides object life-time information for signal listeners (see Signal.Listener) that are implemented as inner classes, helping to avoid the typical memory leak problem related when an object is only reachable through an inner class listener object connected to a signal.
By storing the signal listener within the WObject and using a weak reference from within the Signal class, the object and listener will be reclaimed when only referenced (using a weak reference) from the listener.

See Also:
Signal.addListener(WObject, eu.webtoolkit.jwt.Signal.Listener)
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    protected static class  WObject.FormData  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
      WObject()
    Default constructor.
    protected WObject​(WObject parent)  
  • Method Summary

    Modifier and Type Method Description
    protected void addChild​(WObject child)  
    java.lang.String getId()
    Returns the (unique) identifier for this object
    java.lang.String getObjectName()
    Returns the object name.
    void remove()
    Disconnects listeners owned by the object from signals.
    protected void setFormData​(WObject.FormData formData)  
    void setObjectName​(java.lang.String name)
    Sets an object name.
    static WString tr​(java.lang.String intlKey)
    Creates a localized string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • addChild

      protected void addChild​(WObject child)
    • setObjectName

      public void setObjectName​(java.lang.String name)
      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 getId().

      The default object name is empty.

      Parameters:
      name - the object name.
    • getObjectName

      public java.lang.String getObjectName()
      Returns the object name.
      Returns:
      the object name.
    • getId

      public java.lang.String getId()
      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 getObjectName() with a unique number.

    • setFormData

      protected void setFormData​(WObject.FormData formData)
    • tr

      public static WString tr​(java.lang.String intlKey)
      Creates a localized string. This is a convenience method for WString.tr(String).
    • remove

      public void remove()
      Disconnects listeners owned by the object from signals. This method provides automatic connection management, forcing signal disconnection. Note that signals would be automatically disconnected when the object is garbage collected (and signals use weak references to allow garbage collection of an object which is otherwise no longer referenced but is still connected by signals).