[Seaside] Seaside vs. Aida
Sebastian Sastre
ssastre at seaswork.com
Mon Mar 31 00:15:02 UTC 2008
Is not a secret Rob. I have at hand this login component I've made. I'll comment
on the code the most important methods:
Login>>createComponents
"Creates the subcomponents of the receiver."
super createComponents.
self
at: #username put: (MVPLabeledPresenter new
label: 'Username';
at: #presenter put: (MVPTextInputPresenter new
submitOnEnter: true;
yourself);
yourself);
at: #password put: (MVPToolbar new "I use a toobar here just as a layout
convenience"
at: #input
putTool: (MVPLabeledPresenter new
label: 'Password';
at: #presenter put: (MVPPasswordInputPresenter new
submitOnEnter: true;
yourself);
yourself);
at: #memory
putTool: (MVPAnchorButton new
model: 'I forgot my password/username';
yourself);
yourself);
at: #signIn put: (MVPSubmitButton new
model: 'Sign in';
voidCallback; "so it wont submit"
yourself);
yourself
Login>>model: aModel
"Sets the model of the receiver."
super model: aModel.
"Aspect values are cool because they transparently will get the fresh value with
each render
or set it if they are submitted."
self username model: (aModel aspectValue: #username).
(self password at: #input) model: (aModel aspectValue: #password).
Login>>makeLayout
| keys |
keys := #(
username
password
signIn
) asOrderedCollection.
"This creature cames from a kind family of layout policies
and they know how to deal with tables so we can't forget about them"
^(MVPVerticalFlowLayout createFor: self)
order: keys;
yourself
Login>>wireEvents
"Makes the wiring of events for the receiver.
This events are in fact announcements in the server (not the ones at DOM).
This wiring is meant to establish loose coupling between children and parent
presenters"
super wireEvents.
self signIn
subscribe: MVPSubmitButtonPressed send: #onSignInPressed: to: self;
yourself.
Login>>onSignInPressed: anAnnouncement
self answer: (self session userOrNilFor: self model)
"Here are a couple of methods related to the DOM part of the login"
Login>>installDOMElementBehaviorOn: html
"Returns the script that installs the methods in the
DOM Element which is an homologue of the receiver."
^(super installDOMElementBehaviorOn: html)
add: (self elementOn: html) asJQElement curvyCorner;
add: ((self username presenter focusOn: html) timeout: 100);
add: (self assign: (self onSignInClickedFunctionOn: html) as:
'onSignInClicked' on: html);
"Here I hook a DOM event for the homologue of the receiver and wire it to a
custom reaction.
This can be done also with custom events (thanks to fire introduced in Prototype
1.6.0)"
add: (self signIn
elementOn: #click
call: 'onSignInClicked'
with:'anEvent' asSUObject
in: (self elementOn: html)
on: html);
yourself
Login>>onSignInClickedFunctionOn: html
"Returns the function which will render as javascript at DOM.
Filters submits with no username so server is not bothered
with this kind of spureous requests."
^ SUFunction new argument: 'anEvent';
add: ((((self username presenter formElementOn: html) value
access: 'length') > 1)
then: (SUForm new id: 'systemForm') submit
else: (SUScript new
add: 'anEvent' asSUEvent stop;
add: (html effect highlight id: (self username elementOn: html));
add: (self username presenter formElementOn: html) focus;
yourself));
yourself
I hope you get the idea,
cheers,
Sebastian
_____
De: seaside-bounces at lists.squeakfoundation.org
[mailto:seaside-bounces at lists.squeakfoundation.org] En nombre de Rob Rothwell
Enviado el: Domingo, 30 de Marzo de 2008 17:05
Para: Seaside - general discussion
Asunto: Re: [Seaside] Seaside vs. Aida
On Sun, Mar 30, 2008 at 3:52 PM, Sebastian Sastre <ssastre at seaswork.com> wrote:
nice clarification. I think I discovered my framework uses Seaside as
platform to be able to make something conceptually very similar to what you
described. Anyway my code would look more similar to a esktop development.
Can you give me an example of your code (kind of like Janko just did)? What are
you developing (unless it's a secret!)? Have you built an additional layer on
top of Seaside?
Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20080330/4f156ff8/attachment-0001.htm
More information about the seaside
mailing list