|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.server.AbstractClientConnector
com.vaadin.ui.AbstractComponent
public abstract class AbstractComponent
An abstract class that defines default implementation for the
Component interface. Basic UI components that are not derived from an
external component can inherit this class to easily qualify as Vaadin
components. Most components in Vaadin do just that.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.vaadin.ui.Component |
|---|
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener |
| Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector |
|---|
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener |
| Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable |
|---|
Sizeable.Unit |
| Field Summary |
|---|
| Fields inherited from interface com.vaadin.server.Sizeable |
|---|
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS |
| Constructor Summary | |
|---|---|
AbstractComponent()
Constructs a new Component. |
|
| Method Summary | ||
|---|---|---|
void |
addListener(Component.Listener listener)
Registers a new (generic) component event listener for the component. |
|
void |
addShortcutListener(ShortcutListener shortcut)
|
|
void |
addStyleName(java.lang.String style)
Adds one or more style names to this component. |
|
void |
attach()
Notifies the connector that it is connected to an application. |
|
void |
beforeClientResponse(boolean initial)
Called before the shared state and RPC invocations are sent to the client. |
|
void |
detach()
Notifies the connector that it is detached from the application. |
|
|
findAncestor(java.lang.Class<T> parentType)
Returns the closest ancestor with the given type. |
|
protected void |
fireComponentErrorEvent()
Emits the component error event. |
|
protected void |
fireComponentEvent()
Emits the component event. |
|
protected void |
focus()
Sets the focus for this component if the component is Focusable. |
|
protected ActionManager |
getActionManager()
Gets the ActionManager used to manage the
ShortcutListeners added to this Field. |
|
java.lang.String |
getCaption()
Gets the caption of the component. |
|
ErrorMessage |
getComponentError()
Gets the component's error message. |
|
java.lang.Object |
getData()
Gets the application specific data. |
|
java.lang.String |
getDebugId()
Deprecated. As of 7.0. Use getId() |
|
java.lang.String |
getDescription()
Gets the component's description, used in tooltips and can be displayed directly in certain other components such as forms. |
|
ErrorMessage |
getErrorMessage()
Gets the error message for this component. |
|
float |
getHeight()
Gets the height of the object. |
|
Sizeable.Unit |
getHeightUnits()
Gets the height property units. |
|
Resource |
getIcon()
Gets the icon resource of the component. |
|
java.lang.String |
getId()
Get's currently set debug identifier |
|
java.util.Locale |
getLocale()
Gets the locale of the component. |
|
HasComponents |
getParent()
Gets the parent component of the component. |
|
java.lang.String |
getPrimaryStyleName()
Gets the primary style name of the component. |
|
protected com.vaadin.shared.AbstractComponentState |
getState()
Returns the shared state bean with information to be sent from the server to the client. |
|
protected com.vaadin.shared.AbstractComponentState |
getState(boolean markAsDirty)
Returns the shared state for this connector. |
|
java.lang.String |
getStyleName()
Gets all user-defined CSS style names of a component. |
|
float |
getWidth()
Gets the width of the object. |
|
Sizeable.Unit |
getWidthUnits()
Gets the width property units. |
|
boolean |
isConnectorEnabled()
Checks if the communicator is enabled. |
|
boolean |
isEnabled()
Tests whether the component is enabled or not. |
|
boolean |
isImmediate()
|
|
boolean |
isReadOnly()
Tests whether the component is in the read-only mode. |
|
boolean |
isVisible()
Tests the visibility property of the component. |
|
void |
removeListener(Component.Listener listener)
Removes a previously registered component event listener from this component. |
|
void |
removeShortcutListener(ShortcutListener shortcut)
|
|
void |
removeStyleName(java.lang.String style)
Removes one or more style names from component. |
|
void |
setCaption(java.lang.String caption)
Sets the component's caption String. |
|
void |
setComponentError(ErrorMessage componentError)
Sets the component's error message. |
|
void |
setData(java.lang.Object data)
Sets the data object, that can be used for any application specific data. |
|
void |
setDebugId(java.lang.String id)
Deprecated. As of 7.0. Use setId(String) |
|
void |
setDescription(java.lang.String description)
Sets the component's description. |
|
void |
setEnabled(boolean enabled)
Enables or disables the component. |
|
void |
setHeight(float height,
Sizeable.Unit unit)
Sets the height of the object. |
|
void |
setHeight(java.lang.String height)
Sets the height of the component using String presentation. |
|
void |
setIcon(Resource icon)
Sets the component's icon. |
|
void |
setId(java.lang.String id)
Adds an unique id for component that get's transferred to terminal for testing purposes. |
|
void |
setImmediate(boolean immediate)
Sets the component's immediate mode to the specified status. |
|
void |
setLocale(java.util.Locale locale)
Sets the locale of this component. |
|
void |
setParent(ClientConnector parent)
Sets the parent connector of the connector. |
|
void |
setPrimaryStyleName(java.lang.String style)
Changes the primary style name of the component. |
|
void |
setReadOnly(boolean readOnly)
Sets the read-only mode of the component to the specified mode. |
|
void |
setSizeFull()
Sets the size to 100% x 100%. |
|
void |
setSizeUndefined()
Clears any size settings. |
|
void |
setStyleName(java.lang.String style)
Sets one or more user-defined style names of the component, replacing any previous user-defined styles. |
|
void |
setVisible(boolean visible)
Sets the visibility of the component. |
|
void |
setWidth(float width,
Sizeable.Unit unit)
Sets the width of the object. |
|
void |
setWidth(java.lang.String width)
Sets the width of the component using String presentation. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.vaadin.ui.Component |
|---|
getUI |
| Methods inherited from interface com.vaadin.server.ClientConnector |
|---|
addAttachListener, addDetachListener, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler |
| Methods inherited from interface com.vaadin.shared.Connector |
|---|
getConnectorId |
| Constructor Detail |
|---|
public AbstractComponent()
| Method Detail |
|---|
public void setId(java.lang.String id)
Component
setId in interface Componentid - An alphanumeric idpublic java.lang.String getId()
Component
getId in interface Component@Deprecated public void setDebugId(java.lang.String id)
setId(String)
@Deprecated public java.lang.String getDebugId()
getId()
public java.lang.String getStyleName()
ComponentThe style names are returned only in the basic form in which they were added; each user-defined style name shows as two CSS style class names in the rendered HTML: one as it was given and one prefixed with the component-specific style name. Only the former is returned.
getStyleName in interface ComponentComponent.setStyleName(String),
Component.addStyleName(String),
Component.removeStyleName(String)public void setStyleName(java.lang.String style)
Component
Label label = new Label("This text has a lot of style");
label.setStyleName("myonestyle myotherstyle");
Each style name will occur in two versions: one as specified and one that
is prefixed with the style name of the component. For example, if you
have a Button component and give it "mystyle" style, the
component will have both "mystyle" and "v-button-mystyle"
styles. You could then style the component either with:
.myonestyle {background: blue;}
or
.v-button-myonestyle {background: blue;}
It is normally a good practice to use addStyleName() rather than this setter, as different software
abstraction layers can then add their own styles without accidentally
removing those defined in other layers.
This method will trigger a RepaintRequestEvent.
setStyleName in interface Componentstyle - the new style or styles of the component as a space-separated
listComponent.getStyleName(),
Component.addStyleName(String),
Component.removeStyleName(String)public void setPrimaryStyleName(java.lang.String style)
ComponentThe primary style name identifies the component when applying the CSS theme to the Component. By changing the style name all CSS rules targeted for that style name will no longer apply, and might result in the component not working as intended.
To preserve the original style of the component when changing to a new primary style you should make your new primary style inherit the old primary style using the SASS @include directive. See more in the SASS tutorials.
setPrimaryStyleName in interface Componentstyle - The new primary style namepublic java.lang.String getPrimaryStyleName()
ComponentComponent.setPrimaryStyleName(String) for a better description of
the primary stylename.
getPrimaryStyleName in interface Componentpublic void addStyleName(java.lang.String style)
Component
Label label = new Label("This text has style");
label.addStyleName("mystyle");
Each style name will occur in two versions: one as specified and one that
is prefixed wil the style name of the component. For example, if you have
a Button component and give it "mystyle" style, the
component will have both "mystyle" and "v-button-mystyle"
styles. You could then style the component either with:
.mystyle {font-style: italic;}
or
.v-button-mystyle {font-style: italic;}
This method will trigger a RepaintRequestEvent.
addStyleName in interface Componentstyle - the new style to be added to the componentComponent.getStyleName(),
Component.setStyleName(String),
Component.removeStyleName(String)public void removeStyleName(java.lang.String style)
Component
The parameter must be a valid CSS style name. Only user-defined style
names added with addStyleName() or
setStyleName() can be removed; built-in
style names defined in Vaadin or GWT can not be removed.
RepaintRequestEvent.
removeStyleName in interface Componentstyle - the style name or style names to be removedComponent.getStyleName(),
Component.setStyleName(String),
Component.addStyleName(String)public java.lang.String getCaption()
Component
See Component.setCaption(String) for a detailed description of the
caption.
getCaption in interface Componentnull if the caption is
not set.Component.setCaption(String)public void setCaption(java.lang.String caption)
String. Caption is the visible
name of the component. This method will trigger a
RepaintRequestEvent.
setCaption in interface Componentcaption - the new caption String for the component.public java.util.Locale getLocale()
Component
If a component does not have a locale set, the locale of its parent is
returned, and so on. Eventually, if no parent has locale set, the locale
of the application is returned. If the application does not have a locale
set, it is determined by Locale.getDefault().
As the component must be attached before its locale can be acquired, using this method in the internationalization of component captions, etc. is generally not feasible. For such use case, we recommend using an otherwise acquired reference to the application locale.
getLocale in interface Componentnull if the component and
none of its parents has a locale set and the component is not yet
attached to an application.public void setLocale(java.util.Locale locale)
// Component for which the locale is meaningful
InlineDateField date = new InlineDateField("Datum");
// German language specified with ISO 639-1 language
// code and ISO 3166-1 alpha-2 country code.
date.setLocale(new Locale("de", "DE"));
date.setResolution(DateField.RESOLUTION_DAY);
layout.addComponent(date);
locale - the locale to become this component's locale.public Resource getIcon()
Component
See Component.setIcon(Resource) for a detailed description of the icon.
getIcon in interface Componentnull if the
component has no iconComponent.setIcon(Resource)public void setIcon(Resource icon)
RepaintRequestEvent.
setIcon in interface Componenticon - the icon to be shown with the component's caption.Component.getIcon(),
Component.setCaption(String)public boolean isEnabled()
ComponentAs a security feature, all updates for disabled components are blocked on the server-side.
Note that this method only returns the status of the component and does not take parents into account. Even though this method returns true the component can be disabled to the user if a parent is disabled.
isEnabled in interface Componenttrue if the component and its parent are enabled,
false otherwise.VariableOwner.isEnabled()public void setEnabled(boolean enabled)
Component
Button enabled = new Button("Enabled");
enabled.setEnabled(true); // The default
layout.addComponent(enabled);
Button disabled = new Button("Disabled");
disabled.setEnabled(false);
layout.addComponent(disabled);
This method will trigger a RepaintRequestEvent for the component
and, if it is a ComponentContainer, for all its children
recursively.
setEnabled in interface Componentenabled - a boolean value specifying if the component should be enabled
or notpublic boolean isConnectorEnabled()
ClientConnector
isConnectorEnabled in interface ClientConnectorisConnectorEnabled in class AbstractClientConnectorpublic boolean isImmediate()
public void setImmediate(boolean immediate)
RepaintRequestEvent.
immediate - the boolean value specifying if the component should be in the
immediate mode after the call.Component#isImmediate()public boolean isVisible()
ComponentVisible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent. Making a component invisible through this property can alter the positioning of other components.
A component is visible only if all its parents are also visible. This is not checked by this method though, so even if this method returns true, the component can be hidden from the user because a parent is set to invisible.
isVisible in interface Componenttrue if the component has been set to be visible in
the user interface, false if notComponent.setVisible(boolean),
Component.attach()public void setVisible(boolean visible)
ComponentVisible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.
TextField readonly = new TextField("Read-Only");
readonly.setValue("You can't see this!");
readonly.setVisible(false);
layout.addComponent(readonly);
A component is visible only if all of its parents are also visible. If a component is explicitly set to be invisible, changes in the visibility of its parents will not change the visibility of the component.
setVisible in interface Componentvisible - the boolean value specifying if the component should be
visible after the call or not.Component.isVisible()public java.lang.String getDescription()
ComponentGets the component's description, used in tooltips and can be displayed directly in certain other components such as forms. The description can be used to briefly describe the state of the component to the user. The description string may contain certain XML tags:
| Tag | Description | Example |
| <b> | bold | bold text |
| <i> | italic | italic text |
| <u> | underlined | underlined text |
| <br> | linebreak | N/A |
| <ul> <li>item1 <li>item1 </ul> |
item list |
|
These tags may be nested.
getDescription in interface ComponentStringpublic void setDescription(java.lang.String description)
getDescription() for more
information on what the description is. This method will trigger a
RepaintRequestEvent.
The description is displayed as HTML in tooltips or directly in certain
components so care should be taken to avoid creating the possibility for
HTML injection and possibly XSS vulnerabilities.
description - the new description string for the component.public HasComponents getParent()
Component
Components can be nested but a component can have only one parent. A
component that contains other components, that is, can be a parent,
should usually inherit the ComponentContainer interface.
getParent in interface ClientConnectorgetParent in interface com.vaadin.shared.ConnectorgetParent in interface ComponentgetParent in class AbstractClientConnectorpublic void setParent(ClientConnector parent)
ClientConnector
This method automatically calls ClientConnector.attach() if the connector
becomes attached to the application, regardless of whether it was
attached previously. Conversely, if the parent is null and the
connector is attached to the application, ClientConnector.detach() is called for
the connector.
This method is rarely called directly. One of the
ComponentContainer.addComponent(Component) or
AbstractClientConnector.addExtension(Extension) methods are
normally used for adding connectors to a parent and they will call this
method implicitly.
It is not possible to change the parent without first setting the parent
to null.
setParent in interface ClientConnectorsetParent in class AbstractClientConnectorparent - the parent connectorpublic <T extends HasComponents> T findAncestor(java.lang.Class<T> parentType)
To find the Window that contains the component, use Window w =
getParent(Window.class);
T - The type of the ancestorparentType - The ancestor class we are looking for
public ErrorMessage getErrorMessage()
public ErrorMessage getComponentError()
public void setComponentError(ErrorMessage componentError)
componentError - the new ErrorMessage of the component.public boolean isReadOnly()
ComponentField
components normally have a value that can be input or changed by the
user, this is mostly relevant only to field components, though not
restricted to them.
Notice that the read-only mode only affects whether the user can change the value of the component; it is possible to, for example, scroll a read-only table.
The method will return true if the component or any of its
parents is in the read-only mode.
isReadOnly in interface Componenttrue if the component or any of its parents is in
read-only mode, false if not.Component.setReadOnly(boolean)public void setReadOnly(boolean readOnly)
Component
As only Field components normally have a value that can be input
or changed by the user, this is mostly relevant only to field components,
though not restricted to them.
Notice that the read-only mode only affects whether the user can change the value of the component; it is possible to, for example, scroll a read-only table.
This method will trigger a RepaintRequestEvent.
setReadOnly in interface ComponentreadOnly - a boolean value specifying whether the component is put
read-only mode or notpublic void attach()
ClientConnector
The caller of this method is ClientConnector.setParent(ClientConnector) if the
parent is itself already attached to the application. If not, the parent
will call the ClientConnector.attach() for all its children when it is attached
to the application. This method is always called before the connector's
data is sent to the client-side for the first time.
The attachment logic is implemented in AbstractClientConnector.
attach in interface ClientConnectorattach in interface Componentattach in class AbstractClientConnectorpublic void detach()
AbstractClientConnector
The caller of this method is ClientConnector.setParent(ClientConnector) if the
parent is in the application. When the parent is detached from the
application it is its responsibility to call ClientConnector.detach() for each
of its children.
The AbstractClientConnector.getSession() and AbstractClientConnector.getUI() methods might return
null after this method is called.
detach in interface ClientConnectordetach in class AbstractClientConnectorprotected void focus()
Focusable.
protected com.vaadin.shared.AbstractComponentState getState()
getState in class AbstractClientConnectorprotected com.vaadin.shared.AbstractComponentState getState(boolean markAsDirty)
AbstractClientConnector
getState in class AbstractClientConnectormarkAsDirty - true if the connector should automatically be marked dirty,
false otherwise
AbstractClientConnector.getState()public void beforeClientResponse(boolean initial)
ClientConnector
This method must not alter the component hierarchy in any way. Calling
ClientConnector.markAsDirty() from this method will have no effect.
beforeClientResponse in interface ClientConnectorbeforeClientResponse in class AbstractClientConnectorinitial - true if the client-side connector will be created
and initialized after this method has been invoked.
false if there is already an initialized
client-side connector.public void addListener(Component.Listener listener)
Component
class Listening extends CustomComponent implements Listener {
// Stored for determining the source of an event
Button ok;
Label status; // For displaying info about the event
public Listening() {
VerticalLayout layout = new VerticalLayout();
// Some miscellaneous component
TextField name = new TextField("Say it all here");
name.addListener(this);
name.setImmediate(true);
layout.addComponent(name);
// Handle button clicks as generic events instead
// of Button.ClickEvent events
ok = new Button("OK");
ok.addListener(this);
layout.addComponent(ok);
// For displaying information about an event
status = new Label("");
layout.addComponent(status);
setCompositionRoot(layout);
}
public void componentEvent(Event event) {
// Act according to the source of the event
if (event.getSource() == ok)
getWindow().showNotification("Click!");
status.setValue("Event from " + event.getSource().getClass().getName()
+ ": " + event.getClass().getName());
}
}
Listening listening = new Listening();
layout.addComponent(listening);
addListener in interface Componentlistener - the new Listener to be registered.Component.Event,
Component.removeListener(Listener)public void removeListener(Component.Listener listener)
Component
removeListener in interface Componentlistener - the listener to be removed.Component.addListener(Listener)protected void fireComponentEvent()
protected void fireComponentErrorEvent()
public void setData(java.lang.Object data)
data - the Application specific data.public java.lang.Object getData()
setData(Object).
public float getHeight()
Sizeable
getHeight in interface Sizeablepublic Sizeable.Unit getHeightUnits()
Sizeable
getHeightUnits in interface Sizeablepublic float getWidth()
Sizeable
getWidth in interface Sizeablepublic Sizeable.Unit getWidthUnits()
Sizeable
getWidthUnits in interface Sizeable
public void setHeight(float height,
Sizeable.Unit unit)
Sizeable
setHeight in interface Sizeableheight - the height of the object.unit - the unit used for the width.public void setSizeFull()
Sizeable
setSizeFull in interface Sizeablepublic void setSizeUndefined()
Sizeable
setSizeUndefined in interface Sizeable
public void setWidth(float width,
Sizeable.Unit unit)
Sizeable
setWidth in interface Sizeablewidth - the width of the object.unit - the unit used for the width.public void setWidth(java.lang.String width)
Sizeable
setWidth in interface Sizeablewidth - in CSS style string representation, null or empty string to
resetpublic void setHeight(java.lang.String height)
Sizeable
setHeight in interface Sizeableheight - in CSS style string representationprotected ActionManager getActionManager()
ActionManager used to manage the
ShortcutListeners added to this Field.
public void addShortcutListener(ShortcutListener shortcut)
public void removeShortcutListener(ShortcutListener shortcut)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||