Last active
June 11, 2018 13:29
-
-
Save macprzepiora/665597644c9e7b39c2746872a579f149 to your computer and use it in GitHub Desktop.
Vaadin 10 code showing an issue with required TextField https://github.com/vaadin/vaadin-text-field-flow/issues/82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.przepiora.mac; | |
import com.vaadin.flow.component.dependency.HtmlImport; | |
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | |
import com.vaadin.flow.component.textfield.TextField; | |
import com.vaadin.flow.data.binder.Binder; | |
import com.vaadin.flow.router.Route; | |
@HtmlImport("styles/shared-styles.html") | |
@Route("") | |
public class MainView extends VerticalLayout { | |
public MainView() { | |
Binder<PersonBean> binder = new Binder<>(PersonBean.class); | |
PersonBean joeDeveloper = new PersonBean(); | |
joeDeveloper.setFirstName("Joe"); | |
joeDeveloper.setLastName("Developer"); | |
binder.setBean(joeDeveloper); | |
TextField firstName = new TextField(); | |
TextField lastName = new TextField(); | |
binder.forField(firstName) | |
.withValidator(s -> s.equals("Joe"), "Must be Joe") | |
.asRequired() | |
.bind("firstName"); | |
binder.forField(lastName).bind("lastName"); | |
add(firstName, lastName); | |
} | |
public static class PersonBean { | |
private String firstName; | |
private String lastName; | |
public String getFirstName() { | |
return firstName; | |
} | |
public void setFirstName(String firstName) { | |
this.firstName = firstName; | |
} | |
public String getLastName() { | |
return lastName; | |
} | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment