Validation status reported on UI is not in sync with the binder
See original GitHub issueWith following code snippet:
- write a letter to input
- delete the letter from input
- click the button
- binder reports valid bean, UI shows invalid value in the TextField
Test code:
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.BeanValidationBinder;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.router.Route;
import javax.validation.constraints.NotNull;
import java.util.Set;
@Route("")
public class MainView extends VerticalLayout {
public static class Entity {
@NotNull
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return "Entity, name: " + name;
}
}
final TextField name = new TextField();
public MainView() {
final VerticalLayout layout = new VerticalLayout();
name.setLabel("Type your name here:");
Entity entity = new Entity();
Binder<Entity> b = new BeanValidationBinder<>(Entity.class);
b.bindInstanceFields(this);
b.setBean(entity);
Button button = new Button("Check validity");
button.addClickListener(e -> {
String msg = String.format("Binder.isValid: %s", b.isValid());
Notification.show(msg);
});
add(name, button);
}
}
Note, the code snippet is related to https://github.com/vaadin/framework/issues/9000 (which is valid for Flow as well), but the issue here is different.
Issue Analytics
- State:
- Created 5 years ago
- Comments:20 (20 by maintainers)
Top Results From Across the Web
Binding Data to Forms | Data Binding | Vaadin Docs
The Binder class allows you to define how the values in a business object are bound to fields in the UI. Binder reads...
Read more >Using Binder IPC | Android Open Source Project
This page describes changes to the binder driver in Android 8, provides details on using binder IPC, and lists required SELinux policy.
Read more >CRM: Sync – Veeva Product Support Portal
This section provides solution articles for Veeva CRM Sync issues. Veeva CRM mobile users initiate a sync process to send all their data......
Read more >UIPL 03-04 Attachment - Unemployment Insurance
Cases where a claimant in continued claim status is reporting wages which may ... The ±2 percent error tolerance for validation was designed...
Read more >Known Exploited Vulnerabilities Catalog | CISA
The vulnerabilities are due to insufficient validation of user-supplied ... SP1 and Sitefinity before 10.0.6412.0 does not properly protect Telerik.Web.UI.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it would be fine to make
setRequiredIndicatorVisible(true)
overwritecheckValidity()
to something that only looks at theinvalid
property, and thensetRequiredIndicatorVisible(false)
removes that overwrite.If you’re using e.g.
<vaadin-text-field>
without Binder and want to make it required, then you should use theTextField::setRequired
method instead ofsetRequiredIndicatorVisible
.I don’t have that could understanding of all small details currently, but if I got it right, I think this is a good start.
I hope we can then continue fixing vaadin/framework#9000 😉 It would be nice to have that fixed for LTS version.