No callback function for plugins.file.showFileOpenDialog() ?

Is there a way to remove a callback function from plugins.file.showFileOpenDialog() call? It works with an empty callback function but would be more efficient without one:

function uploadVCardDialog(){

	var vCardFile = plugins.file.showFileOpenDialog(1, null, false, null, uploadCallBack, i18n.getI18NMessage('bob.ps_vcard_upload'))[0];

	return parseVCard(vCardFile);
}

function uploadCallBack(_file){}

If I place null instead of uploadCallBack I get error.

IN case of web-client you need a callback!
in case of smart-client, did you try setting it to null?

Yes, it doesn’t work for smart client with “null”.

it should work fine for a smart client with null
then we return directly the files and the dialog is blocking

For a webclient if you provide null it will thrown an exception.

I tried numerous times, as soon as I substitute call to empty “function uploadCallBack(_file){}” with “null” it stops working. This is in smart clients. The code is in the top message. Remove “uploadCallBack” from “showFileOpenDialog” and it stops working.

i guess you are getting an exception in the log/console right?
Because you are in single select (that 3th argument which is false) but you do in the end [0] but a single select only return directly the file…
no need for an array index lookup there.
If you are giving a callback you should really use the return value because thats should be handled in the calback

Sorry, actually I did change the code. There is no more [0] there:

function uploadVCardDialog(){

	var vCardFile = plugins.file.showFileOpenDialog(1, null, false, null, uploadCallBack, i18n.getI18NMessage('bob.ps_vcard_upload'));

	return (vCardFile && vCardFile.length)?parseVCard(vCardFile[0]):{};}



function uploadCallBack(_file){}

it doesn’t work anyway.

If I do in smartclient without the callback null

$file		= plugins.file.showFileOpenDialog(1, null, false, new Array("XLS and XLSX", "xls", "xlsx"));

I get no errors, when I hover the showFileOpenDialog I see this

Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled, you must set the callback method for this to work)

so I think in smartclient the callback null is not needed (I never use it in smartclient)…

Peter

it works fine but again now you are given in that example a uploadCallBack AND you do something with the return value… (which STILL does [0])

just do this:

var vCardFile = plugins.file.showFileOpenDialog(1, null, false, null, null, i18n.getI18NMessage(‘bob.ps_vcard_upload’));
application.output(vCardFile)

and you will see that you get a file just fine.

Finally figured it out. Thank you!