Dears,
In my Edit screen, I have 2 dropdowns: One for the list of projects, and one of the list of services within each project.
When the user selects a project, the services dropdown should display the list of services pertaining to the selected project.
I have done this using the PostInit() method:
protected void postInit() {
super.postInit();
activationAdjustmentsDs.addItemPropertyChangeListener(e -> {
ActivationAdjustments curActivationAdjustment = (ActivationAdjustments) e.getItem();
// Filter the services drop down based on the selected project
If (e.getProperty().equals("projectId")) {
if (curActivationAdjustment.getProjectId() != null) {
projectServiceIdField.setEditable(true);
int curProjectId = curActivationAdjustment.getProjectId().getId();
projectServicesDs.setQuery("select e from billing$ProjectServices e where e.projectId.id = "
+ curProjectId
+ " and e.cancelled = false and e.recurringPeriod > 0 and e.terminationDate is null order by e.id");
projectServicesDs.refresh();
}
}
});
Assume I have 2 projects P1 (with services a and b) and P2 (with services c and d).
The user picks P2, the services dropdown shows c and d. The user selects service c.
Then he changes his mind and selects P1. The service dropdown still shows c, and when the user clicks on the arrow of the dropdown, it shows c, a and b. It is not until the user chooses a or b that the option c is removed.
Appreciate your feedback on how to fix this issue.
Regards,
Shady