Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binder.setBean writes read only fields back to bean #9446

Closed
jool77 opened this issue Nov 20, 2020 · 5 comments · Fixed by #10768
Closed

Binder.setBean writes read only fields back to bean #9446

jool77 opened this issue Nov 20, 2020 · 5 comments · Fixed by #10768

Comments

@jool77
Copy link

jool77 commented Nov 20, 2020

When Binding a field as read only and calling Binder.setBean the current behavior is such that field value gets written back to bean. If field has one-way converter defined this destroys the field value in bean as converter convertToModel is called, which should not happen for read only fields. For example in our case the value is some object and it needs to be converted to String for presentation. However it is not possible to convert value back from String. This kind of scenario should be possible, when defining field binding as read only. In such case only convertToPresentation should be called.

test.zip

Steps to reproduce the behavior:

  1. Run included test program
  2. Click on 'Set bean' button
  3. See log and check bean field value from printed output

Expected behavior would be in this case that ExampleBean.vals field would stay intact and won't be null as the field binding is defined as read only.

  • OS: macOS Catalina 10.15.7
  • Browser Firefox
  • Version 81.0
  • Vaadin platform version 14.3.8
@ZheSun88 ZheSun88 transferred this issue from vaadin/platform Nov 20, 2020
@pleku pleku added this to Needs triage in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) via automation Nov 23, 2020
@pleku pleku moved this from Needs triage to New P2 in OLD Vaadin Flow bugs & maintenance (Vaadin 10+) Nov 23, 2020
@pleku
Copy link
Contributor

pleku commented Nov 23, 2020

Expected behavior would be in this case that ExampleBean.vals field would stay intact and won't be null as the field binding is defined as read only.

Hello. I'd say this is how it should go and this is a bug.

@denis-anisimov denis-anisimov self-assigned this Apr 20, 2021
OLD Vaadin Flow bugs & maintenance (Vaadin 10+) automation moved this from WIP to Closed Apr 23, 2021
mshabarov pushed a commit that referenced this issue Apr 26, 2021
mshabarov pushed a commit that referenced this issue Apr 26, 2021
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 20.0.0.alpha8. For prerelease versions, it will be included in its final version.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 14.6.0.rc1. For prerelease versions, it will be included in its final version.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 14.5.5. For prerelease versions, it will be included in its final version.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 19.0.7. For prerelease versions, it will be included in its final version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment