summaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorIlia Motornyi <elmot@vaadin.com>2018-03-20 18:30:28 +0200
committerGitHub <noreply@github.com>2018-03-20 18:30:28 +0200
commit940a1ef584c82e343474863408771ff091044bdc (patch)
tree9fe6ab321f7cf6f298a09b72409550f236def7e7 /documentation
parent4b1dd9f54cff3d7768e672ea42b36bbfa3ff60c4 (diff)
downloadvaadin-framework-940a1ef584c82e343474863408771ff091044bdc.tar.gz
vaadin-framework-940a1ef584c82e343474863408771ff091044bdc.zip
Implement ReadOnlyHasValue helper (#10643)
Diffstat (limited to 'documentation')
-rw-r--r--documentation/datamodel/datamodel-forms.asciidoc12
1 files changed, 12 insertions, 0 deletions
diff --git a/documentation/datamodel/datamodel-forms.asciidoc b/documentation/datamodel/datamodel-forms.asciidoc
index f307144a57..5be66f81ea 100644
--- a/documentation/datamodel/datamodel-forms.asciidoc
+++ b/documentation/datamodel/datamodel-forms.asciidoc
@@ -91,6 +91,18 @@ binder.bind(nameField,
}
});
----
+== Binding non-modifiable Data
+
+Non-modifiable data can be also bound to any component or component property with [classname]#ReadOnlyHasValue# helper class.
+For example, `Panel` caption can display a person full name:
+
+[source, java]
+----
+Panel infoPanel = new Panel();
+ReadOnlyHasValue<Person> panelTitle = new ReadOnlyHasValue<>(
+ person -> infoPanel.setCaption(person.getLastName() + ", " + person.getFirstName()));
+binder.forField(panelTitle).bind(person -> person, null);
+----
== Validating and Converting User Input