[aida] Re usable Components in Seaside & Aida

Frank Young franklin1 at runbox.com
Fri Jan 30 23:56:53 CET 2009



Nicolas Petton wrote:
> 
> Le vendredi 30 janvier 2009 à 00:42 -0800, Frank Young a écrit :
>> After learning a little about Seaside, I just tried out Aida/Web
>> recently.  I
>> found it simpler and easier to pick up than Seaside. In fact, Aida
>> reminds
>> me of Ruby on Rails in some ways, with its emphasis on naming and
>> convention.  Methods are named viewXXXX and actionXXXX; models are named
>> YYYY while their corresponding WebApplications are named YYYYApp.  Of
>> course, Smalltalk provides a much faster and more productive development
>> environment than any Ruby IDE.
>> 
>> The most striking difference between Seaside and Aida that people have
>> pointed out, of course, is control flow.  Seaside permits WAcomponents to
>> be
>> called, just like a subroutine, which facilitates reusability of that
>> component.  Moreover, a WAComponent can also be rendered within a page as
>> well, further enhancing its reusability.
>> 
>> As an example, consider a WAComponent that acts as a login page,
>> prompting a
>> user for username and password:
>> 
>> LoginComponent>>renderContentOn: html
>> 	html form: [
>> 		html text: 'Login: '.
>>          html textInputOn: #username of: self; break.
>>          html text: 'Password: '.
>>          html passwordInputOn: #password of: self;break.
>>          html submitButtonWithAction: [
>> 			self authenticate] text: 'Login']]
>> 
>> In Seaside, one can call this LoginComponent
>> 
>> 		self call: LoginComponent new
>> 
>> to have a login page pop up, or one can render an embedded LoginComponent
>> within the current page:
>> 
>> 		html render: loginComponent
>> 
>> similar to how a Java applet can function either as an applet or as a
>> Java
>> application (if called from an AWT Frame).
>> 
>> I think this is one of the strong points of Seaside in permitting
>> WAComponents to be used in different contexts, so that programmers can
>> easily develop a library of reusable components.
>> 
>> From what I have seen of Aida, it uses a state machine-like process to
>> transition and navigate among different web pages rather than Seaside's
>> subroutine-like flow control.  I wonder, though, how Aida supports
>> reusable
>> components given this distinction.
> 
> We have several examples of resuable components in Aida. See WebGrid
> class for example. I also a counter example for Aida:
> http://nico.bioskop.fr/blog/a-multi-counter-with-aida/web.html
> 
> and the demo: http://nico.bioskop.fr/multicounter.html
> 
> As you can see, components in Aida heavily use Ajax, but as it is deeply
> integrated in Aida, you shouldn't even notice it, except for some method
> names!
> 
> to try a multicounter by yourself, load the class and methods from my
> post, then in any application, add a view like this:
> 
> viewCounters
> 	| e |
> 	e := WebElement new.
> 	self counters do: [:each |
> 	e add: each].
> 	self pageFrameWith: e title: 'multi-counters'
> 
> counters
> 	^counters ifNil: [
> 		counters := {CounterComponent new.
> 			{CounterComponent.
> 			{CounterComponent}]
> 
> cheers!
> 
> nico
> 
> 

Hi Nico,

Thanks for providing that CounterComponent example of reusable components in
Aida.  I think that illustrates what I was referring to as an embeddable
component, which Seaside embeds into a current page using:

    self render: counterComponent

To make an Aida component reusable as an embeddable component, it needs to
subclass from WebComponent or WebElement, as opposed to WebApplication,
while in Seaside all components subclass from WAComponent.

Furthermore, a model named YYYY would have a corresponding WebApplication
named YYYYApp if an YYYY object were url-linked

    e addLinkTo: yyyy text: 'some text'

so that if the yyyy instance is selected, Aida would delegate the view to
YYYYApp.  To reference the model instance yyyy from YYYYApp would require
calling

    self observee

from YYYYApp (Are there any other uses of WebApplication in Aida besides
being used as a delegated view of a model?).

In embeddable components, however, all of this delegation goes away.  The
CounterComponent does not use the observer pattern to obtain a reference to
the model.  The model has to be an instVar of CounterComponent:

    WebComponent subclass: #CounterComponent
	instanceVariableNames: 'counter'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'CounterDemo'

   CounterComponent>>initialize
       counter := Counter new

So I guess one distinction between url-linked components and embeddable
components in Aida is that url-linked components use delegation to reference
the model, while embeddable components use composition, whereas in Seaside
all WAComponents use composition.

You also mentioned:



> As you can see, components in Aida heavily use Ajax, but as it is deeply
> integrated in Aida, you shouldn't even notice it, except for some method
> names!
> 

Is it necessary for components to use Ajax, rather than to simply refresh or
update the page (I'm still somewhat uneasy about Ajax, and usually prefer to
design sites without it if possible)?

Frank

-- 
View this message in context: http://www.nabble.com/Reusable-Components-in-Seaside---Aida-tp21743322p21757246.html
Sent from the AIDA/Web mailing list archive at Nabble.com.



More information about the Aida mailing list