showFileOpenDialog callback arguments

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

showFileOpenDialog callback arguments

Postby steve1376656734 » Thu Apr 28, 2016 11:51 am

Hi,

When using the plugins.file.showFileOpenDialog call in a web-client environment you need to specify a callback method that is called on completion of the dialog. Is it possible to pass arguments to this callback (other than the standard array of JSFile objects that servoy passes)?

If so how and if not would anyone else see this as a useful feature request?

Thanks
Steve
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 338
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK

Re: showFileOpenDialog callback arguments

Postby ROCLASI » Thu Apr 28, 2016 12:05 pm

Hi Steve,

I don't think this is possible. But I also fail to see the benefit of this. Maybe I am missing something.
What would you want to pass to the showFileOpenDialog to send back to your callback method?
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: showFileOpenDialog callback arguments

Postby steve1376656734 » Thu Apr 28, 2016 12:26 pm

Hi Robert

I want to send a record ID to be used to associate with the document that has been uploaded. As this is an asynchronous process, when the callback method is invoked there is no guaranteed way of identifying which record was selected at the point the upload request was made. If I am reading the docs correctly then in the smart client the callback is not necessary and the file objects are returned to the method that called the dialog and so it is easy to deal with the necessary parameters. For example in the smart client:

Code: Select all
/**
* Upload a document
*
* @param {UUID} recordId
*
* @author Steve Hawes
* @since  2016-04-25
*
* @public
*
* @properties={typeid:24,uuid:"E9A877FF-D63B-41B9-8BC9-E6EA40F36E9F"}
*/
function uploadDocument(recordId) {
   var filesObj = plugins.file.showFileOpenDialog(1, null, false, scopes.svyDocumentManagement$impl.getDocumentFilter(), null, i18n.getI18NMessage(scopes.tmleMessages.title.confirm));
   filesObj.forEach(function(f) {
      // Do something here with both the file object and the record ID
   });
}


However in the web client (and presumably the NG client) the callback is necessary as the FilesObj will contain nothing. When the callback is then invoked it has no knowledge of the recordId and trying to use global variables or checking the foundset in forms does not guarantee that you will get the correct information as it may have changed in the meantime.

Hopefully I've explained it well enough so that my use case is clearer now?

It may also be the case that I am misunderstanding the process - in which case I would be happy to be enlightened :D

Thanks
Steve
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 338
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK

Re: showFileOpenDialog callback arguments

Postby patrick » Thu Apr 28, 2016 12:34 pm

Why not simply set whatever arguments you want to a variable and retrieve that in the callback?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3708
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: showFileOpenDialog callback arguments

Postby steve1376656734 » Thu Apr 28, 2016 12:45 pm

Maybe this is my general lack of understanding of the process but I thought that would be a bad idea as that variable could be modified before the callback is invoked.

The whole premise for this problem is my assumption that the showFileOpenDialog process does not block during the upload. If that is true then the user could initiate an upload (thereby setting the values into a variable) and before the upload has completed and therefore invoked the callback they could begin another upload and overwrite the values stored in the global variable.

If this is not the case and the process does block user input then using a global is a viable (and easy) way around my issue so I guess my original question should have been "Does the showFileOpenDialog block all user input until the upload is complete and the callback has been invoked?" :D
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 338
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK

Re: showFileOpenDialog callback arguments

Postby patrick » Thu Apr 28, 2016 12:47 pm

I understand the point and I am not sure what happens. Why not try out? Upload 200 MB and then upload 1 kb files and see what happens?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3708
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: showFileOpenDialog callback arguments

Postby steve1376656734 » Thu Apr 28, 2016 12:52 pm

I will test it out and share my findings.
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 338
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK


Return to Web Development

Who is online

Users browsing this forum: No registered users and 3 guests