Custom Message Dialog

Hi all,

I need to upload many documents for a NEW customer.
The Document is a separate entity and the relation with Client is Composition.
The document has also a reference with the customer which is many-to-one

I ADDED a MultiUploadFile to select these files in the CustomerEdit window, since the proper MultiUpload on the DocumentEditor gave me “cascade-perist” or “duplicate-pk (on the client)” error while tryng to add these documents from there (no errors with a pre-existent customer).

So I finally found a “solution” for the errors metioned.

I added an AfterCommitListener() on the CONTEXT in the ClientEdit delegate.
In this listener I

  • get the newClient form the context
    For Every files
  • store the file with fileUploadingAPI.putFileIntoStorage()
  • create the new document with metadata.create() and do newDoc.setClient(newClient)

All is working well, but I need to inform the user when the upload is in progress while uploading files, especially big ones.

I tryed the showNotification() but it is bad since I can’t close the window if the upload terminates before the window timeout, with the result that many notification are displayed overlapped on the screen.

To solve this problem I created a custom screen with a label which is

  • opened before the upload
  • updated every time a file is uploaded.
  • not closed on pourpose after all files are downloaded

Even with this method I had no luck since this widow it is displayed only after all files are uploaded and the CustomerEdit is closed

So the final question: how can I display some kind of message while uploading files and a final message when the work is done?

In alternative, is there a better method to do the work?



Have you tried FileUploadDialog?

Hi Olga,
no because I need to upload multiple files at once. It is a customer request

FileMultiUploadField displays its own dialog with a progress bar on the client side while loading, and you cannot do anything in parallel or override this dialog. You only can handle the upload result with the help of QueueUploadCompleteListener.

If you do need to modify the standard dialog with a progress bar, you can either create your own file upload component or try to use an existing one, for example, Vaadin EasyUploads plugin.

Also, you can create another topic on this forum to solve your "cascade-persist” or “duplicate-pk” error. Maybe this will save you from doing magic on file upload.

you just have me realized that the upload process is already managed by the component by transfering files from the client to the tmp directory. I used two big files to check it.
I was mistakenly convinced that was the putFileIntoStorage function doing this work.

Now I realized that there is no need to inform the client with other messages of any kind.

As for the "cascade-persist’ or “duplicate-pk” maybe you are right again, If something will be wrong when the work is completed I will follow your advice.

Thank you,

1 Like