The Rookie Rides Again - File Explorer?

Hi all,

Ok, I’m probably missing something really obvious here, but I’ve look around without finding an answer, so here I am. I’d like my users to be able to select a file from a location on disk, basically like clicking on"Browse" in many Windows applications. To me, that seems like really obvious functionality, but I can’t seem to figure out how to do it in Servoy. I’ve looked in the Solution examples, in the Servoy for Beginner’s book, in the Servoy 5 doc, and here on the Forum. I could have missed something, of course, but so far I haven’t found anything that can just be dropped in. The File plugin has a couple of things that look like they could be used to build a file browser/explorer, but with something like Servoy, it seems like that’d be something you could just drop in. So, I’m thinking I just missed something really obvious.

Of course, I’d like something that will work cross-platform as well :o I’ve looked around at some 3rd party java beans, but so far haven’t found anything. Of course, I could just be searching for the wrong thing.

Any clues as to what I’ve missed?

As always, thanks a lot for any thoughts you might have.

Ron

To me what you want sounds exactly like:

https://wiki.servoy.com:8443/display/pu … e-readFile

so essentially:

var theFile = plugins.file.readFile()

Hi Jan,

I hope that you and yours are doing well.

Thanks for that information. I’ve looked at that, and while I could be misreading it, what I think that function is doing is actually reading the contents of the file. What I’m trying to find is something a bit like Windows File Browser, that is, when you click on My Computer, you get a list of available drives, if you double click on a drive, you get a list of folders and files at the root of that drive, double click on a folder and you get a list of the contents of that folder, etc. The functionality I’m hoping for is the ability of a user to be able to add, say, an image to his database by browsing through the file/folder structure until he finds his file, and then click “open”, or some such thing. Same as if you’re looking for a file to open in Word or StarOffice or something like that. Basically, what I’m trying to do is avoid having the user have to type in the fully qualified file name manually in order to bring an image into the system, and instead just have him browse until he finds it.

Sorry for not being clearer in my explanation.

I will take a look again at readfile, but I think that that is doing something else. Of course, I’ve been wrong before :D

Thanks again.

Ron

RonG:
Basically, what I’m trying to do is avoid having the user have to type in the fully qualified file name manually in order to bring an image into the system, and instead just have him browse until he finds it.

That is exactly what my example does. You can even push it straight into a blob if that is what you want to do:

blobfield = plugins.file.readFile()

yeah, plugins.file.readFile() without arguments, does open a filechooser.

If you want more options, look at: plugins.file.showFileOpenDialog()

Hi Jan,

I stuck the code into a test form I have, and darned if it didn’t do exactly what you said! :D Turns out that when I looked at the notes that came along with the function, I missed the part about it popping up the file dialog if you don’t give it a file.

Thanks a lot. Exactly what I was looking for.

Would you happen to know if this will also function for the Mac and on the Web Client?

Thanks again.

Ron

Thanks to you, also, Harjo, for the additional information.

Ron

RonG:
Would you happen to know if this will also function for the Mac and on the Web Client?

It works on Mac and Linux, not in web client. In web client you can put a blob field (display type is image_media) on a form. If it is editable it will have a file chooser attached to it automatically.

Hi Jan,

Thanks, I’ll give that a try. It’s working great on the smart client, by the way. Just what I needed. :D

Have a good day.

Ron