Hello together, can someone tell my how it is possible to handle a class with a collection field (e.g. ArrayList,…).
I have the class Project with some fields like projectname, date and so one. Among that fields I have a LinkedList for gathering Strings (Names of people who work on that project).
public class Project implements Serializable, Cloneable {
private Long id;
private String name = "";
private ProjectDateSpecification specification;
private String description = "";
private String password = "";
private String peopleNeeded;
private List<String> participants = new LinkedList<String>();
methods......
I the class ProjecForm I have this code to add a participants name to the String list of the current project:
participate2.setClickShortcut(KeyCode.ENTER);
participate2.addClickListener(e -> {
this.addParticipant(project, participateName.getValue());
// project.addParticipant(participateName.getValue());
myUI.updateList();
participateName.clear();
setVisible(false);
});
}
private void addParticipant(Project project2, String value) {
service.addParticipate(project2, value);
}
In my UI i have a grid from which my Projects are accessible.
Attached you can find a picture how it should work.
Unfortunately I add the new participant also to other projects when i click this button and I don’t know why.
Does anyone have a good solution for this issue?
regards Paul