Dynamic Web Development with Seaside

17.3.2Referencing FileLibrary files by URL

How you use a file library depends on what you want to do with the files in it. As you’ve seen in the previous sections, using image, music, style sheets and JavaScript files requires knowing their URL. You can find the URL of any document in your file library by sending the class WAFileLibrary class>>urlOf:. For example, if you had added the file picture.jpg to your library and you want to display it in a component you would write something like:

MyClass>>renderContentOn: html
html image url: (MyFileLibrary urlOf: #pictureJpg)

The URL returned by urlOf: is relative to the current server. It does not contain the http://servername.com/ - the so-called “method and “host - portion of the URL. Note that WAFileLibrary implements a class method called /, so the expression MyFileLibrary / #pictureJpeg is equivalent to MyFileLibrary urlOf: #pictureJpeg.

Once you know the URL of the FileLibrary resources you can use them to include style sheets and JavaScript in your components as we have already discussed.

Copyright © 22 April 2024 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.