I'm required to make a quick fix on a class, where a method, that processes files on a dropzone and mails them with a press of a button, gets a Dropzone as a parameter. However there's a bug that there will be multiple instances of the said Dropzone. Each time a window is opened, a new dropzone is created...
Whenever the dropzone validation fails (wrong type of file dragged on it, or pressing the button with no files on the dropzone), there will be as many error windows showing in the client as there are instances of the dropzone.
I know that's a horrible bug made by the guy before me, but right now I would only need to refer to the most recent instance of the said DropZone within the method when making the error window pop-up.
Now, the question is, how can I refer within the method ONLY to the instance of the dropzone which was given as a parameter for the method and ignoring all the underlying other instances of it, thus avoiding the "incrementation" of error windows?
Here's some relevant code:
@Inject
private Instance<Toast> toast;
final DropZone dropZone = createDropzone(FORMDOCUMENT, "placeholder");
windowLayout.addComponent(dropZone)
private void processDropzoneFiles(DropZone dropZone) {
...
if (!dropZone.hasItems()) {
toast.get().show("Error message"), Toast.ToastType.ERROR);
}
...
}