Class Label

Label component for showing non-editable short texts. The label content can be set to the modes specified by the final members CONTENT_*

The contents of the label may contain simple formatting:

  • <b> Bold

  • <i> Italic

  • <u> Underlined

  • <br/> Linebreak

  • <ul><li>item 1</li><li>item 2</li></ul> List of items

The b , i , u and li tags can contain all the tags in the list recursively.

Synopsis

Since

3.0

Inheritance Path.  java.lang.Object-> com.itmill.toolkit.ui.AbstractComponent -> com.itmill.toolkit.ui.Label

Label()

Creates an empty Label.

Label(Property)

Creates a new instance of Label with text-contents read from given datasource.

Label(Property, int)

Creates a new instance of Label with text-contents read from given datasource.

Label(String)

Creates a new instance of Label with text-contents.

Label(String, int)

Creates a new instance of Label with text-contents.

CONTENT_DEFAULT

The default content mode is plain text

CONTENT_PREFORMATTED

Content mode, where the label contains preformatted text.

CONTENT_RAW

Content mode, where the label contains RAW output. Output is not required to comply to with XML. In Web Adapter output is inserted inside the resulting HTML document as-is. This is useful for some specific purposes where possibly broken HTML content needs to be shown, but in most cases XHTML mode should be preferred.

CONTENT_TEXT

Content mode, where the label contains only plain text. The getValue() result is coded to XML when painting.

CONTENT_UIDL

Formatted content mode, where the contents is XML restricted to the UIDL 1.0 formatting markups.

CONTENT_XHTML

Content mode, where the label contains XHTML. Contents is then enclosed in DIV elements having namespace of "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".

CONTENT_XML

Content mode, where the label contains well-formed or well-balanced XML. Each of the root elements must have their default namespace specified.

addListener(Property.ValueChangeListener)

Parameters

listener

Listener to be added.

Add value change listener

compareTo(Object)

Parameters

other

Other object to compare to

return

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

See Also
java.lang.Comparable.compareTo

Compare Label to other objects.

Labels can be compared to other labels for sorting label contents. This is especially handy for sorting table columns.

In RAW, PREFORMATTED and TEXT modes, the label contents are compared as is. In XML, UIDL and XHTML modes, only CDATA is compared and tags ignored. If the other object is not a Label, its toString() return value is used in comparison.

getContentMode()

Parameters

return

Content mode of the label.

Get the content mode of the Label.

Possible content modes include:

  • CONTENT_TEXT Content mode, where the label contains only plain text. The getValue() result is coded to XML when painting.

  • CONTENT_PREFORMATTED Content mode, where the label contains preformatted text.

  • CONTENT_UIDL Formatted content mode, where the contents is XML restricted to the UIDL 1.0 formatting markups.

  • CONTENT_XHTML Content mode, where the label contains XHTML. Contents is then enclosed in DIV elements having namespace of "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".

  • CONTENT_XML Content mode, where the label contains well-formed or well-balanced XML. Each of the root elements must have their default namespace specified.

  • CONTENT_RAW Content mode, where the label contains RAW output. Output is not required to comply to with XML. In Web Adapter output is inserted inside the resulting HTML document as-is. This is useful for some specific purposes where possibly broken HTML content needs to be shown, but in most cases XHTML mode should be preferred.

getPropertyDataSource()

Get viewing data-source property.

getTag()

Parameters

return

Component UIDL tag as string.

Get component UIDL tag.

getType()

Parameters

return

type of the Property

Description copied from interface: getType

Returns the type of the Property. The methods getValue and setValue must be compatible with this type: one must be able to safely cast the value returned from getValue to the given type and pass any variable assignable to this type as an argument to setValue .

getValue()

Parameters

return

Value of the label

Get the value of the label. Value of the label is the XML contents of the label.

isReadOnly()

Parameters

return

True iff the component is in read only mode

Is the component read-only ? Readonly is not used in label - this returns allways false.

paintContent(PaintTarget)

Parameters

event

PaintEvent.

Paint the content of this component.

removeListener(Property.ValueChangeListener)

Parameters

listener

Listener to be removed.

Remove value change listener

setContentMode(int)

Parameters

contentMode

New content mode of the label.

Set the content mode of the Label.

Possible content modes include:

  • CONTENT_TEXT Content mode, where the label contains only plain text. The getValue() result is coded to XML when painting.

  • CONTENT_PREFORMATTED Content mode, where the label contains preformatted text.

  • CONTENT_UIDL Formatted content mode, where the contents is XML restricted to the UIDL 1.0 formatting markups.

  • CONTENT_XHTML Content mode, where the label contains XHTML. Contents is then enclosed in DIV elements having namespace of "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".

  • CONTENT_XML Content mode, where the label contains well-formed or well-balanced XML. Each of the root elements must have their default namespace specified.

  • CONTENT_RAW Content mode, where the label contains RAW output. Output is not required to comply to with XML. In Web Adapter output is inserted inside the resulting HTML document as-is. This is useful for some specific purposes where possibly broken HTML content needs to be shown, but in most cases XHTML mode should be preferred.

setPropertyDataSource(Property)

Set the property as data-source for viewing.

setReadOnly(boolean)

Parameters

readOnly

True to enable read-only mode, False to disable it

Set the component to read-only. Readonly is not used in label.

setValue(Object)

Parameters

newValue

New value of the label

Set the value of the label. Value of the label is the XML contents of the label.

toString()

Parameters

return

String representation of the value stored in the Property

Description copied from interface: toString

Returns the value of the Property in human readable textual format. The return value should be assignable to the setValue method if the Property is not in read-only mode.

valueChange(Property.ValueChangeEvent)

Listen value change events from data source.