[Seaside] Newbie questions

Julian Fitzell seaside@lists.squeakfoundation.org
Tue, 13 Aug 2002 12:45:38 -0700

Alain Fischer wrote:
> Hi Pablo,
> I have not used Seaside for a while, the following tips could have changed
> with recent version of Seaside.

Indeed they have a little.  You must not have seen my reply yet but I'll 
comment a little more here on the differences for those who care.

>> 1)   If I have:
>>         Test>html
>>             ^'<img src="image.gif">'
>>       where should I put the file "image.gif" to get it displayed on the
>> browser ?
> - You must have a static content server (Comanche is able to do this)
> - You must configure the "Document Root" of your application in Seaside
>    to point to your static content server.

This is a little outdated.  In Seaside 0.93 we used a URL as the 
document root and if you made an img tag dynamic (@src="..." instead of 
src="...") then it would prepend the URL of the document root to the 
image name.  As of 0.94, though, image tags do not need to be dynamic, 
they work be noticing the "resource/" portion of the URL and looking up 
the Document Root which is now a filesystem path.  Note that this trick 
also work with <a href="resource/foo">Link to foo</a>

>> 2) I have a jsp/asp background (and a little of zope) and I found that is
>> much easier to write html code outside Squeak. Is there a way to use file
>> based templates ? (I saw the class IAFileTemplate but I couldn't 
>> figure out
>> how to use it).
> In your component define the following method:
> template
>     ^ IAFileTemplate new
>         file: 'toto.html';
>         bindWith: [:t | self addBindingsTo: t]

Again, this code works in 0.93 but is slightly different with 0.94.x

#bindWith: is no longer used and a call to #addHandlers is used instead 
of #addBindingsTo:.  Also, the template is stored in an instvar and 
should be created only when the instvar is nil.  The instvar gets set to 
nil whenever the template needs to be flushed (with a file template, 
basically only if you change the #addHandlers method).  IAFileTemplate 
itself implements a check to see whether the file on disk has changed 
since it was last loaded and reloads it if necessary.

Beta4 Productions (http://www.beta4.com)