0

I have two combo boxes named Name and Project and a check box named Reject. when I select one element from Name and one from Project and when I click on reject, It should be stored in database and when I try to select same elements next time, I would like to generate a notification that this name has been rejected.

This is what I have so far. When I click on check box, Name and Project combo boxes are disabled or read only. How should I store the state of check box along with combo box's selected values in database ?

private void nameListener(ComboBox<Employee> employeeComboBox) {
                employeeComboBox.addValueChangeListener(event -> {
                    event.getValue().getPerson();

                    });


            }
            private void projectListener(ComboBox<Project> projectComboBox) {
                projectComboBox.addValueChangeListener(event -> {
                    event.getValue().getName();

                });
            }

            private void checkboxListener(CheckBox rejectCheckBox) { 
                rejectCheckBox.addValueChangeListener(event ->{
                    if (event.getValue()== true) {
                        nameListener(employeeComboBox);
                        projectListener(projectComboBox);
                        employeeComboBox.setReadOnly(true);
                        projectComboBox.setReadOnly(true);
                    }
                    else {
                        employeeComboBox.setReadOnly(false);
                        projectComboBox.setReadOnly(false);
                    }
                }) ;
            }
AlfaBet
  • 3
  • 2
  • Create separate listener which you will assign to value changed on each components (So it will be shared for both), inside you can make validation if in each components are selected values correctly and make requested action. – xxxvodnikxxx Apr 27 '18 at 11:07
  • Welcome on Stackoverflow. Please read in the [help center](https://stackoverflow.com/help) for some guidelines on asking. In particular, you should provide more details of the exact problem and what you have tried so far to solve it (e.g. show some code). For example: Do you have problems accessing a database? Or do you have problems with combo box event listeners? – Steffen Harbich May 02 '18 at 12:35

0 Answers0