OL Filebrowser FAQ
Ok, after introducing my OL Filebrowser class, here is part 2 to answer most of the possible questions about using this class:
Attributes
Despite the general attributes applible to an object of the OL window class the following attributes have been implemented:
- DirPath: The starting directory on the server – aka the root you like to show
- SrcPath: The URL to call for getting the directory listing
- callAttributes: If you require additional parameters added over the script providing the directory listing, define an object with attribute-value pairs like here:
callAttributes="${{menuname:'read_mediadir'}}" - autoclose: if a file is selected the window closes automatically. If this behaviour is not wishful, turn it of by setting it to false; Default: true.
- value: if a file was selected, this attribute contains the filename
Methods
These are just the major methods you’re going to use during normal usage:
- open: Opens the window and loads the current directory again. So selection is resetted
- takeSelection: Parameters: [func:Function], [target:Object]
The closing function of the class. Sets the value of the Object to the selected document (if any) otherwise null. If [func] and [target] is set, the function [func] is called as a method of [target] and with the path of the selected document as parameter.
If autoclose is true, the window is closed. - getCurrentDir: returns the full current directory path starting with the directory specified in DirPath
XML input
The object uses the standard HTTP request of its “fileListSet” dataset. A parameter “dir” is set to the path of the directory to read and the callAttributes are added if there are any.
The Response of the serverside script then should look like this:
<list>
<file type="DS_Store" size="12292" date="2008-04-08 08:44:12">
<name><![CDATA[.DS_Store]]></name>
<full><![CDATA[/Users/myuser/path/to/file.jpg]]></full>
</file>
<file type="directory" size="476" date="2007-10-02 22:15:43">
<name><![CDATA[classes]]></name>
<full><![CDATA[/Users/myuser/path/to/dir]]></full>
</file>
</list>
The structure is quite straight forward. The filesize is in bytes and is converted into KB or MB by the object. The type attribute can have any value. Only “directory” is important to identify directories.
openlaszlo file browser
Ok, my last post was about 12 Month ago. Ay, hard times since then, but i’ve developed my openlaszlo skills and today i’m proud to introduce my first really useful openlaszlo class.
For a project i needed a decent file browser, showing the files on the webserver and letting the user to select a file. So, if you need something like that (see pictures below), go ahead and grab a copy of the filebrowser openlaszlo class files.


How to use:
1. Copy the filebrowser.class.lzx file and the filebrowser_buttons directory to your openlaszlo application directory
2. Include the class-file like every library:
<include href="filebrowser.class.lzx"/>
3. and put an instance on your canvas like here:
<filebrowserclass name="fileBrowser" x="20" y="20" width="600" height="400" DirPath="files/" SrcPath="http://localhost/path/to/xml/provider.php" callAttributes="${{menuname:'read_mediadir'}}">
<button text="Cancel" onclick="parent.close()"/>
<button text="Select" onclick="parent.takeSelected(Debug.write,Debug)"/>
</filebrowserclass>
Yep, that’s it.
Ok, i know you’ll still have more questions, so i’ll post a short FAQ on the next post.