From a1a8977082c3d89aee0b5ec9fdf6d8a3b09f5c6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Tue, 19 Jul 2016 11:39:04 +0300 Subject: [PATCH] BoV: Components/Label: Remove references to old databinding Change-Id: I329c725b545df065c1bea133438d685cf7fd9791 --- .../components/components-label.asciidoc | 58 ++----------------- 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/documentation/components/components-label.asciidoc b/documentation/components/components-label.asciidoc index 424e5ae76c..f225c6ba73 100644 --- a/documentation/components/components-label.asciidoc +++ b/documentation/components/components-label.asciidoc @@ -31,9 +31,8 @@ layout.addComponent(label); ---- See the http://demo.vaadin.com/book-examples-vaadin7/book#component.label.basic[on-line example, window="_blank"]. -[classname]#Label# implements the [interfacename]#Property# interface to allow -accessing the text value, so you can get and set the text with -[methodname]#getValue()# and [methodname]#setValue()#. +You can get and set the text of a [classname]#Label# with the +[methodname]#getValue()# and [methodname]#setValue()# methods. [source, java] ---- @@ -42,18 +41,11 @@ TextField editor = new TextField(null, // No caption label.getValue()); // Change the label's text -editor.addValueChangeListener(event -> // Java 8 - label.setValue(editor.getValue())); -editor.setImmediate(true); // Send on Enter +editor.onChange(label::setValue); +// or onChange(value -> label.setValue(value)); ---- See the http://demo.vaadin.com/book-examples-vaadin7/book#component.label.basic[on-line example, window="_blank"]. -Label also supports data binding to a property data source, as described later -in <>. However, in that case the value can not be -set through the label, as [classname]#Label# is not a -[interfacename]#Property.Editor# and is not allowed to write to a bound -property. - Even though [classname]#Label# is text and is often used as a caption, it is a normal component and therefore also has a caption that you can set with [methodname]#setCaption()#. As with most other components, the caption is @@ -248,48 +240,6 @@ horizontal.addComponent(button2); endif::web[] -[[components.label.databinding]] -== Data Binding - -While [classname]#Label# is not a field component, it is a -[interfacename]#Property.Viewer# and can be bound to a property data source, -described in -<>. -You can specify the data source either in the constructor or by the -[methodname]#setPropertyDataSource()# method. - - -[source, java] ----- -// Some property -ObjectProperty property = - new ObjectProperty("some value"); - -// Label that is bound to the property -Label label = new Label(property); ----- -See the http://demo.vaadin.com/book-examples-vaadin7/book#component.label.binding[on-line example, window="_blank"]. - -Further, as [classname]#Label# is a [interfacename]#Property#, you can edit its -value with a property editor, such as a field: - - -[source, java] ----- -Label label = new Label("some value"); -TextField editor = new TextField(); -editor.setPropertyDataSource(label); -editor.setImmediate(true); ----- -See the http://demo.vaadin.com/book-examples-vaadin7/book#component.label.delegation[on-line example, window="_blank"]. - -However, [classname]#Label# is __not__ a [interfacename]#Property.Editor#, so it -is read-only when bound to a data source. Therefore, you can not use -[methodname]#setValue()# to set the value of a connected data source through a -[classname]#Label# nor bind the label to an editor field, in which case writes -would be delegated through the label. - - [[components.label.css]] == CSS Style Rules -- 2.39.5