[aida] Tutorial, WebStyle
janko.mivsek at eranova.si
Thu Sep 20 23:07:12 CEST 2007
Dirk Verleysen wrote:
> I get a bit further but now I get "Cannot find aWebApplication for object aClubBook".
> My mainView method in ClubBookApp is not accessed.
Actually even and instance of ClubBookApp was not created. This error is
an indication that Aida didn't manage to find an App class for your
domain object. Your domain object class is ClubBook and you also created
a presentation class ClubBookApp (by simply adding App to the domain
class name). This should work, so problem must be somewhere else. On VW
could be a namespace problem. Did you put both ClubBook and ClubBook on
some namespace other than default?
Try to debug that problem by putting a breakpoint in Object>>webAppFor:
or even better in WebApplication class>>newFor:on: This later method
(actually #newFromNameFor:) searches for an App class by composing a
name from domain object class name and then instantiate the found class
to get a presentation object for your domain one.
> This is my simple mainView method
> | e |
> e := WebElement new.
> self halt.
> self title: 'Club Book'.
> e addTextH1: 'Club Book'.
> self pageFrameWith: e title: 'Club Book'
This method looks correct.
> As mentioned in the tutorial I subclassed my ClubBookApp from WebApplication.
> Now it appears that pageFrameWith:title: is not implemented on
> WebApplication so I would think that the tutorial example wouldn't
#pageFrameWith:title: is implemented in WebStyle. And WebStyle is not a
subclass of WebApplication but method search anyway goes to WebStyle.
Namely, a #doesNotUnderstand is overiden in WebApplication to redirect
all unknown methods to an instance of WebStyle (or its subclass) which
is registered in AIDASite style instvar.
Well, this sounds a bit complicated and harder to debug but you will
soon get used to. But this approach has many more advantages:
1. WebStyle deals (as a name suggests) with styling (CSS) of your
web site. And styling is separated from content by separating app and
style classes too. As is HTML separated from CSS in any well formed web
pages those days.
2. You can also separate style on site-by-site basis. That means
that you can have the same Apps for many sites but sites are still
looking differently, because they are using different styling. This is
achieved by sublclassing WebStyle and registering a new class in
3. Web hosting of many web sites on one image is very easy with this
For instance, if you want to make your own CSS style for your ClubBook
1. make your own style class by subclassing WebStyle, like ClubStyle
2. (AIDASite named: 'aidademo') styleClass: 'ClubStyle'.
3. now override css* methods in ClubStyle with your own CSS
4. You can also change #pageFrameWith:title: to have a different framing
of your web pages (different header, footer, navigation bar etc).
I hope that explains a bit one of main mysteries but also main features
Smalltalk Web Application Server
More information about the Aida