[aida] #aidademo implementation

Janko Mivšek janko.mivsek at eranova.si
Tue Jan 20 19:45:16 CET 2009

Prashanth Hebbar wrote:

>     site aidademo? Do you have a method #aidademo implemented somewhere? in
>     AIDASite?

> Prashanth: no. I implemented #aidademo (just copied #demo) but still the 
> mission page points to demo.html. Here's the code fragment from 
> #navBarMainLinksElement:
>     addLinkTo: self site aidademo text: 'Mission' view: #mission;
> Here's the #viewMission code:
>     viewMission
>     | e |
>      e := WebElement new.
>      e addTextH1: 'Content Accounting & Protection Society'. e addBreak.
>      e add: self missionElement.
>      self pageFrameWith: e title: 'CAPS - Mission'

This method you implemented in WebDemoApp, right?

>  and the code for aidademo:
>     aidademo
>      ^self userServices at: #WebDemo
>       ifAbsent:
>        [self addUserService: WebDemo new named: #WebDemo.
>        self urlResolver defaultURL: '/aidademo.html' forObject: self
>     aidademo.
>        ^self aidademo]

Well, you actually reuse the already registered WebDemo, that's why 
addLinkTo: resloves always to the old Url :)

Which is also ok, if you just extended WebDemoApp with additional view? 
If you like to have another WebDemo instance, then correct above method:

	^self userServices at: #AnotherDemo
	self addUserService: WebDemo new named: #AnotherDemo

>  I am little confused with the need to implement an aidademo method in 
> AIDASite. what are we referencing when we are actually executing:
> (AIDASite named 'aidademo') urlResolver...

Yes, this is actually a double registration of root domain object. Why? 
Because the registration in AIDASite's user services is considered more 
safe, more strong than just in url resolver. Remember, loosing a 
reference to a root object is a fatal event, you can loose a while 
domain model at the next garbage collection cycle.

In tutorial registering the root object is only to url resolver because 
of simplicity, but if you look at the real Aida systems, all root 
objects are primary registered elsewhere, mostly in AIDASite user services.

> does this mean that "named:" can have anyName as value? In that case, I 
> kept getting an error with #styleClass:

(AIDASite named: 'site name') is a method to find the instance of 
AIDASite with that name. If you look at the implementation, it first 
asks SwazooServer for its singleton, then ask it to find the site.


Janko Mivšek
Smalltalk Web Application Server

More information about the Aida mailing list