« Return to Thread: #render: or #call: components.

Re: #render: or #call: components.

by David Zmick :: Rate this Message:

Reply to Author | View in Thread

I know that this is probably a very bad practice, but I have initialized component, eg. a instance variable 'bodyComp'
 
ok, I will show some code:
 
RootComponent>>initilaize
   super initialize.
   self bodyComp: BodyComponent new.
 
RootComponent>>renderContentOn: html
   "all the head stuff"
    bodyComponent renderContentOn: html
    "etc."
 
I was wonderering how this was "correctley" done the other day, so I'm glad this thread popped up..  What is bad about my method, if anything, I just think it seems a little hackish...
ty


 
On Mon, Apr 28, 2008 at 9:27 AM, John Thornborrow <john@...> wrote:
Yes, that was what I intended, my example was merely a demonstration of #onAnswer:

John.


Lukas Renggli wrote:
 MyParentComponent>>renderContentOn: html
 html render: (
   ChildComponentA new
     onAnswer: [ :val | self answer: val ];
     yourself).
 html render: (
   ChildComponentB new
     onAnswer: [ :val | self answer: val];
     yourself)

No component instantiation in the render method! Like this you get new
components every time you hit refresh or perform an action on the
page. This certainly does not work as expected.

You probably want something like this:

MyPageComponent>>initialize
   super initialize.
   childA := ChildComponentA new
      onAnswer: [ :val | self answer: val ];
      yourself.
   childB := ChildComponentB new
      onAnswer: [ :val | self answer: val ];
      yourself.

MyPageComponent>>children
   ^ Array with: childA with: childB

MyPageComponent>>renderContentOn: html
   html render: childA.
   html render: childB

Lukas


--
John Thornborrow
http://www.pinesoft.co.uk


******************************************************************************************************************************************
This email is from Pinesoft Limited. Its contents are confidential to the intended recipient(s) at the email address(es) to which it has been addressed. It may not be disclosed to or used by anyone other than the addressee(s), nor may it be copied in anyway. If received in error, please contact the sender, then delete it from your system. Although this email and attachments are believed to be free of virus, or any other defect which might affect any computer or IT system into which they are received and opened, it is the responsibility of the recipient to ensure that they are virus free and no responsibility is accepted by Pinesoft for any loss or damage arising in any way from receipt or use thereof. *******************************************************************************************************************************************


Pinesoft Limited are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA
_______________________________________________



--
David Zmick
/dz0004455\
http://dz0004455.googlepages.com
http://dz0004455.blogspot.com
_______________________________________________
seaside mailing list
seaside@...
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 « Return to Thread: #render: or #call: components.