ValueLabel Add-on
Label that allows binding and value listeners in Vaadin 8.0
ValueLabel extends Label from Vaadin 8.0 and allows the developer to bind data to the component using Binder and to add value change listeners as well.
Sample code
ValueLabel valueLabel = new ValueLabel(String.valueOf(valueInLabel)); VerticalLayout layout = new VerticalLayout(); layout.addComponent(valueLabel); setContent(layout); Binder<MyBean> binder = new Binder<>(MyBean.class); binder.bind(valueLabel, MyBean::getValue, MyBean::setValue); MyBean bean = new MyBean(); bean.setValue("VALUE"); binder.setBean(bean);
private int value = 1; @Override protected void init(VaadinRequest request) { ValueLabel valueLabel = new ValueLabel(String.valueOf(value)); valueLabel.addValueChangeListener(event -> Notification.show("Value Changed")); Button btnChangeValue = new Button("Change value", event -> valueLabel.setValue(String.valueOf(++value))); setContent(new VerticalLayout(valueLabel, btnChangeValue)); }
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
- Released
- 2017-02-25
- Maturity
- STABLE
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 8.0+
- Browser
- Browser Independent
ValueLabel Add-on - Vaadin Add-on Directory
Label that allows binding and value listeners in Vaadin 8.0ValueLabel extends Label from Vaadin 8.0 and allows the developer to bind data to the component using Binder and to add value change listeners as well.