[aida] WebStyle <---> WebApplication

Janko Mivšek janko.mivsek at eranova.si
Tue Apr 1 20:35:55 CEST 2008


Hi Edward,

Edward Stow wrote:

> My question, first up,  how would you create two or more WebStyles for
> a site? and apply these to particular pages (or rather WebApplication
> objects.)

So far no. WebStyle is originally meant to separate design from site to 
site on multi-site hosting environments. For instance I'm running such a 
VW image with 35 sites and each such site has its own subclass of WebStyle.

But why would you actually need WebStyle for each App?

> My question led me to investigate WebApplication and WebStyle a bit
> more closely.  These two  classes seem very coupled and because of the
> obscuring (imho) #dnu: implementation ... that redirects many, many
> messages to the style class it makes it difficult to understand the
> framework.

Yes, this one is funny on first sight but very powerful after you 
understand it. In a way It extends Apps to a WebStyle, but for each site 
differently. But on the other side is hard to debug and hard to 
understand for a newbie. Actually calling style methods explicitly:

		anApp style pageFrameWith:title:

is the best way to go and I'll actually change all my code to use this 
#style method. Thanks for comming out with that idea!

This method was introduced recently, which is the reason of non-use so far.

> 
> WebApplication>>doesNotUnderstand: aMessage
> 	"forward a message to a style for processing"
> 	^self style
> 		perform: aMessage selector
> 		withArguments: aMessage arguments
> 
> My troubles began in the tutorial and the #pageFrameWith:title:
> 
>     viewMain
>         | e |
>         e := WebElement new.
>         e addTextH1: 'Address book'.
>         self pageFrameWith: e title: 'Address book'
> 
>  I guessed that #pageFrameWith:title: must be setting up the page
> layout (the header, menus etc) but was surprised to find that
> #pageFrameWith:title: was not implemented in the WebApplication
> hierarchy.   Why not directly send the message to the WebStyle object
> (and it is less expensive cpu wise) such as:
> 
>         self style pageFrameWith: e title: 'Address book'
> 
> WebStyle seems to me to incorporate at least the following features:
>  -- setup a page template for the *Aida tutorial* site (the  page
> headers, footers, navigation bars etc)
> -- establish assets for the site (html header information - css files,
> images files, script files)

Web site stye in Aida don't mean just CSS, but also a basic layout of 
the page, which is usually HTML. That's why you'll find many basic page 
components defined in WebStyle sublcass, not in app. Specially those 
components, which appear on every page. Reusable components, if you like.

Current WebStyle should better be named as DefaultWebStyle and be 
subclasses from an abstract WebStyle. WebStyle would be just with 
support methods and maybe some default ones like #pageFrameWith: . That 
way it would be easier to subclass by your needs.

> Subclassing WebStyle to create my own web site page template is very
> messy (as per the Joomla example ..)

It's true, for instance currently nulifying superclass css methods needs 
to copy and make them return empty string here. Very inpracticall. We 
need to finally implement that #addSuperStyles for breaking the 
additions of superclass css methods to the final css.

> Sorry for the long message -- in part I need to document these issues
> to better understand them myself.

And we need such questions to improve our docs!

-- 
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si


More information about the Aida mailing list