Class WObject
- Direct Known Subclasses:
AbstractMfaProcess,Login,OAuthAuthorizationEndpointProcess,OAuthProcess,StdLayoutItemImpl,WAbstractArea,WAbstractChartModel,WAbstractColorMap,WAbstractDataSeries3D,WAbstractItemDelegate,WAbstractItemModel,WApplication,WButtonGroup,WCanvasPaintDevice,WCssDecorationStyle,WCssRule,WDataSeries,WFileDropWidget.File,WFormModel,WItemSelectionModel,WLayout,WLeafletMap.AbstractMapItem,WNotification,WResource,WServerGLWidget,WSound,WTableColumn,WTableRow,WTheme,WTimer,WWidget
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:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetId()Returns the (unique) identifier for this objectReturns the object name.voidremove()Disconnects listeners owned by the object from signals.booleanReturns whether the form data should be resent.protected voidsetFormData(WObject.FormData formData) voidsetObjectName(String name) Sets an object name.static WStringCreates a localized string.
-
Constructor Details
-
WObject
public WObject()Default constructor.
-
-
Method Details
-
setObjectName
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
Returns the object name.- Returns:
- the object name.
-
getId
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 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 concatenatinggetObjectName()with a unique number. -
resendFormData
public boolean resendFormData()Returns whether the form data should be resent. This method is called to determine if the form data should be resent to the server. If not overridden, it always returns true. You will probably want to override this method when overridingsetFormData(FormData), to stop the client from resending form data when it is not needed. This method is only called once per update by theWebRenderer. -
setFormData
-
tr
Creates a localized string. This is a convenience method forWString.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).
-