firstName = new TextField("First name");
lastName = new TextField("Last name");
username = new TextField("Username");
password = new PasswordField("Password");
dob = new DatePicker("Date of birth");
sex = new RadioButtonGroup<>();
sex.setLabel("Sex");
sex.setItems(new ArrayList<>(Arrays.asList(MALE, FEMALE)));
sex.setRenderer(new TextRenderer<>(Sex::getName));
email = new EmailField("Email");
binder.forField(firstName).asRequired("First name is required").bind(User::getFirstName, User::setFirstName);
binder.forField(lastName).asRequired("Last name is required").bind(User::getLastName, User::setLastName);
binder.forField(username).asRequired("Username is required").bind(User::getUsername, User::setUsername);
binder.forField(password).asRequired("Password is required").bind(User::getPassword, User::setPassword);
binder.forField(dob).asRequired("Date of birth is required").bind(User::getDateOfBirth, User::setDateOfBirth);
binder.forField(sex).asRequired("Sex is required").bind(User::getSex, User::setSex);
binder.forField(email).asRequired("Email address is required").bind(User::getEmail, User::setEmail);
binder.removeBinding(firstName);
binder.removeBinding(lastName);
binder.removeBinding(username);
binder.removeBinding(password);
binder.removeBinding(dob);
binder.removeBinding(sex);
binder.removeBinding(email);
binder.forField(firstName).asRequired("First name is required").bind(User::getFirstName, User::setFirstName);
binder.forField(lastName).asRequired("Last name is required").bind(User::getLastName, User::setLastName);
binder.forField(username).asRequired("Username is required").bind(User::getUsername, User::setUsername);
binder.forField(password).asRequired("Password is required").bind(User::getPassword, User::setPassword);
binder.forField(dob).asRequired("Date of birth is required").bind(User::getDateOfBirth, User::setDateOfBirth);
binder.forField(sex).asRequired("Sex is required").bind(User::getSex, User::setSex);
binder.forField(email).asRequired("Email address is required").bind(User::getEmail, User::setEmail);
In the first code block, the attached form is initialized. In the second code block, I save the user data, clear all of the fields, and remove the bindings to prevent the required messages from being displayed for each field. I then attach a binder so that the next save will have the required data.
As the first screenshot shows, the required indicators disappear as each field is populated. The radio button does not have the same behavior as the other components as its required indicator never disappears.
As the second screenshot shows, removing the bindings from the fields prevents the required message from being displayed after the last save. Again, the radio button does not have the same behavior as the other components as the required message is still being displayed after the initial binding has supposedly been removed.
I assume binding with the radio button should work just like it does with the other components.