[Seaside] How to perform some action on every page refresh?

Sebastian Sastre ssastre at seaswork.com
Sun Sep 16 12:52:53 UTC 2007


> -----Mensaje original-----
> De: seaside-bounces at lists.squeakfoundation.org 
> [mailto:seaside-bounces at lists.squeakfoundation.org] En nombre 
> de Alexandre Paes
> Enviado el: Sábado, 15 de Septiembre de 2007 21:56
> Para: Seaside - general discussion
> Asunto: Re: [Seaside] How to perform some action on every 
> page refresh?
> 
> First let me thank everyone who answered my question.
> 
> Sebastian Sastre wrote:
> > If I understood you right, you need what Lukas told. Just use the
> > #renderContentOn: of the compoenent like this:
> > 
> > ClientsList>>renderContentOn: html
> > 
> > 	self freshClients do:[:e| self renderClient: e on: html]
> > 	
> > 
> > Then your method #freshClients gets them from whatever you 
> are using 
> > to store and query clients. Everytime the component is rendered 
> > (visited or
> > refreshed) you have the Seaside guarantee of that being executed
> > 
> 
> I must admit this was my first thought, but i actually 
> believe i read somewhere that one should not call 
> non-rendering methods from #renderContentOn:.
> 
> Thanks again everyone for your answers.
> 
> 
> Alexandre

Well, as Phillipe said renderContentOn: should not be called because Seaside
guarantees it's call. But you can allways send a component to render using
#render: (and including it's instVar in #children)

See:

	Clients
		clientsHeader
		clientsList


Clients>>renderContentOn: html

	html div class: #clientsHeader; with: [render: clientsHeader].
	html div class: #clientsList; with: [render: clientsList].

Clients>>children
	^ {clientsHeader. clientsList}

But when is rendered you want guarantee fresh clients, so that's the moment
to provide fresh clients, so that’s when you call them.

By default is less error prone to think "I cant call method in
renderContentOn" but actually you can call non rendering methods but you
just use significant discern for what you're doing calling them (to evade
interference with rendering process, coupling, other bad guys) so to be
aware of it's consequences,

Cheers,

Sebastian



More information about the seaside mailing list