[Seaside] WACompound: creating Seaside Widgets
ryan.craig.simmons at gmail.com
Sat Nov 8 07:59:35 UTC 2008
Descending from WAComponent produces a seaside component this can be
called from or embeded into another seaside component. If you embed a
component into another one you have to add it to the children array.
Advantages each component has its own state that is maintained, uses
#renderContentOn: which is very easy to understand.
Disadvantage must use the children collection to embed it
Descending from WACompound produces a seaside tag that can be embeded
into a seaside component this would be typically called like html
latLongInput on: #postition of: self.
Advantages can easly be added multiple times to a component. Has a
Disadvantages has no state, a new instance is created each time the
page is refreshed.
The added complexity on WADateInput comes from it trying to maintain
the standard tag interface allowing you to use #on:of, #callback:,
Tags use the same canvas to render themselves on as a component but
this is done in the #with: method not in #renderContentOn: you also
use canvas instead of html so for you you could have a #with: method
canvas text: 'latitiude: '.
canvas textInput on: #latitude of: self value.
canvas text: 'longitude: '.
canvas textInput on: #longitude of: self value.
canvas hiddenInput callback: [callbackBlock value: self value]
The hidden callback is used to answer the origional callback defined
on your component either through #on:of: or #callback:
To get a working tag you would probalbly want to redefine #value to
^value ifNil: [value := MyLongitudeLatitudeClass new]
This is not very bulletproof (you have to privide a callback when
rendering (#on:of: is just a shortcut for #value: #callback)) but
On Sat, Nov 8, 2008 at 7:53 AM, Nick Ager <nick.ager at gmail.com> wrote:
> I want to build a widget for latitude, longitude entry ([N|S], lat
> degrees, lat minutes; [E|W] long degrees, long minutes). Looking at
> examples in Seaside it appears I have at least two ways of proceeding:
> 1) Derive from WAComponent eg WADateSelector
> 2) Derive from WACompound eg WADateInput
> In my application I'll be using the latitude and longitude entry in
> multiple places and like the idea of being able to use it directly as
> a brush on the canvas as:
> RenderContentOn: html
> html latLongInput on: #position of: self
> However WADateInput appears to be significantly more complex than
> WADateSelector and I don't entirely understand what is going on. For
> example why in WADateInput>>addCallback is a hiddenInput added? I also
> guess I'd have to modify WARenderCanvas to add something like:
> ^ self brush: NALatitudeLongitudeInput new
> Any thoughts on the relative merits of the two approaches and why are
> there two Date input widgets?
> Thanks in advance
> seaside mailing list
> seaside at lists.squeakfoundation.org
More information about the seaside