The XdevLabel is a non-editable text component that is predominantly used to create single-row text labels for form components or other page elements. However, it is possible to use XdevLabel to create longer text labels with line breaks. The text can also be formatted in HTML and can break automatically.
Important properties:
Caption - Displays text as label.
- ContentMode
- TEXT - Default value. The label contains plain text. All characters are permitted.
- PREFORMATTED - The label contains pre-formatted text. By default, the text is displayed in a monospaced font. The text can contain line breaks and tab characters.
- HTML - The label contains HTML.
Value - Text or value intended to represent the UI component.
Data binding:
Data container (model) - property
A property can be set to implicit with setValue
// Sets the Property label.setValue(true);
or by setting the property of an item as the model. The allocation can, therefore, be achieved using the setPropertyDataSource method.
// Gets a property from the SeletcedItem of a Table with "Product" Entities Property<?> itemProperty = this.table.getSelectedItem().getItemProperty("productname"); // Sets the Property label.setPropertyDataSource(itemProperty);
Examples:
Set text dynamically
label.setValue("New text");
Set text mode dynamically
label.setContentMode(ContentMode.HTML);
Note:
- Automatic line break: For multiple-line text to break automatically, you must edit Toolbox > Weight > 10 and under With > select %.