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

Could binder setter work without total validation? #5143

Open
Mrakobec opened this issue Mar 7, 2024 · 1 comment
Open

Could binder setter work without total validation? #5143

Mrakobec opened this issue Mar 7, 2024 · 1 comment

Comments

@Mrakobec
Copy link

Mrakobec commented Mar 7, 2024

Describe your motivation

Vaadin versin used: 24.3.6
I would to use setter trigger to create Entity on press checkBox (as example in my case) and i have some additional logic to provide this new entity. If I reliaze this logic and i have not valid any another binded field, this setter doesn't work and when checkbox is pressed - nothing happens.

example:
2 Entitys: Auction, Settings;

Auction{
String name;
Setting settings;
}

Settings{
Boolean isPriceHidden;
}

view:

Binder<Auction> auction ...
TextField nameField....
CheckBox hasSettingsCheckBox....
Button changeSettingsBtn...
....
changeSettingsBtn.setVisible(false);
...
binder.forField(nameField).asRequired().....
binder.forField(hasSettingsCheckBox).bind(auction -> auction .getSettings() == null, (auction, aBoolean) -> {
            if(event.getValue()){
                auction.setSettings(null);
            }
            else if(auction.getSettings() == null){
                auction.setSettings(new Settings());
            }
       changeSettingsBtn.setVisible(auction.getSettings() != null);
        });
....

Describe the solution you'd like

I like to setter works locally in exactly field, and don't wait to have all valid fields.
If target field doesn't validate -> setter doesn't work - OK.
If target field is valid -> setter work - OK.
If target field is valid and another field is not valid -> setter doesn't work - WRONG.

Describe alternatives you've considered

now I need to use the valueChangeListener and additional validation, and this look like crutch.

Additional context

No response

@Mrakobec Mrakobec changed the title Would binder setter work without total validation? Could binder setter work without total validation? Mar 7, 2024
@mcollovati
Copy link
Contributor

Probably related to this issue, that has been fixed in Flow and will be released in Vaadin 24.3.7

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

No branches or pull requests

2 participants