[Seaside] [Q] Rendering and components...
Brian Brown
rbb at techgame.net
Tue Apr 1 17:19:51 CEST 2003
On Tuesday 01 April 2003 04:02 pm, Avi Bryant wrote:
> On Tue, 1 Apr 2003, Brian Brown wrote:
> > And in MenuItem (created from the MenuBar):
> > items := OrderedCollection new.
> > items add: (MenuItem new initialize: 'Home' with: HomePage target:
> > target.)
> >
> > This is the code that is in MenuItem>>renderContentOn:
> > renderContentOn: html
> > html anchorWithAction: [target perform: #mainContent with: action.]
> > text: displayName. html hr.
> >
> > Now my traceback says that MNU mainContent and shows self as nil:
>
> So, target must be nil, which means it isn't getting set correctly. What
> does your #initialize:with:target: method look like?
Yes, it is always turning up nil in the debugger, and I've tried quite a few
iterations for the #initialize:with:target (which I'll be changing the name
of ...). It looks like this at present:
initialize: aDisplayString with: anAction target: aTarget
displayName := aDisplayString.
action := anAction.
target := aTarget.
(A side question about syntax... if I have accessor methods on my instance
variables, is it acceptable to do somthing like:
foo := (MenuBar initialize
instanceVar1: var1
instanceVar2: var2)
or do I have to put semi-colons between them?.... ?)
> (By the way, it's
> best to give more descriptive names that give some idea of what the
> parameters are, eg,
> #initializeWithDescription:componentClass:target:).
agreed :)
>
> A couple of other points. #mainContent and #mainContent: are two
> completely different method names, one of which takes 0 parameters and the
> other of which takes one. So (target perform: #mainContent with: action)
> doesn't make any sense - you're trying to pass a parameter to a zero
> argument method, and one which presumably doesn't exist. You would use
> (target perform: #mainContent: with: action) except that there's no sense
> in using #perform: when you know the method name already - you can just
> send the message directly, eg, (target mainContent: action). #perform: is
> used when you don't know what the method is you're trying to call - I used
> it in my example code because each MenuItem was calling a different method
> on the target, but yours don't do that.
>
I understood that difference, but was second guessing myself.
> That make sense?
Yes ;)
>
> Cheers,
> Avi
>
>
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/listinfo/seaside
More information about the Seaside
mailing list