Hi Goran,
I’m using the MultiSelectBox, as following:
(Using Eclipselink for the JPA stack)
An Object “Customer” can have one or more Objects “Applications”
the multiSelectBox has 3 pre-defined applications in the table
-
When creating a customer, I choose the 3 pre-defined objects ‘application’, no problem
-
But When I modify the customer, by un-choosing by example one ‘application’, after saving, this unchoosed Object is ALSO DELETED in the application table
**Why is the unchoosed Object deleted in the application table? **
Many thanks in advance
Model
@Entity
public class Customer {
private Set<Application> applications = new HashSet<Application>();
/**
* @return the applications
*/
@PrivateOwned
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
@OrderBy("name ASC")
public Set<Application> getApplications() {
return applications;
}
/**
* @param applications the applications to set
*/
public void setApplications(Set<Application> applications) {
this.applications = applications;
}
In the View
/*
*
- using the multiselectBox for choosing applications
*/
MultiselectComboBox applications = new MultiselectComboBox();
applications.setPlaceholder(“Choisissez les produits installés…”);
applications.setWidthFull();
applications.setItemLabelGenerator(Application::getName);
List applicationsList = customerService.getApplications(); // all the objects ‘application’ stored in the table ‘application’
applications.setOrdered(true);
if (applicationsList != null && applicationsList.size()>0) {
applications.setItems(new HashSet<>(applicationsList));
}
applications.setClearButtonVisible(true);
binder.bind(applications, Customer::getApplications, Customer::setApplications);