[Seaside] #render: or #call: components.

John Thornborrow john at pinesoft.co.uk
Mon Apr 28 10:47:56 UTC 2008


For that scenario, option 1 would be more suitable - simply because it 
is much more simple and would be easier to maintain.

J.

Edward Stow wrote:
> On Mon, Apr 28, 2008 at 8:07 PM, John Thornborrow <john at pinesoft.co.uk> wrote:
>> Hi,
>>
>>  #call: should only be used in a callback, or when using a WATask subclass.
>> (The latter leaves you no option anyway, as WATasks cannot/do not render)
>>
>>  If you want multiple components rendered on the same page, you must use
>> #render:, if you want to pass control of the session to another component,
>> use #call: within a callback.
> 
> I was aware of the limitations on using #render: and #call: - perhaps
> my elaboration below will better illustrate my question.
>>  It is also worth noting the #onAnswer: message, this allows you to render
>> multiple components and ensure all will do specific action upon answering.
> 
> So .. adding the #onAnswer is the equivalent of using #call: in the
> rendering process?
> 
> Elaboration:
> 
> 1. Displaying sub components with #call:
> -----------------------
> ParentComponent>>renderContentOn: html
> 
> <render heading information >
> html render: ChildComponentA new
> <render footer informaton >
> 
> ChildComponentA>>renderContentOn: html
> 
> html anchor
>     callback: [ self call: ChildComponentB new  ];
>     with: 'Show child component B'
> 
> ChildComponentB>>renderContentOn: html
> 
> html anchor
>     callback: [ self call: ChildComponentA new  ];
>     with: 'Show child component A'
> 
> Or  2. Display with render: in sub components
> ---------------------------------------
> ParentComponent>>renderContentOn: html
> 
>    html render: self bodyComponent.
> 
> #bodyComponent returns either a ChildComponentA or ChildComponentB instance.
> 
> ChildComponentA>>renderContentOn: html
> 
> html anchor
>     callback: [ self showChildComponentB  ];
>     with: 'Show child component B'
> 
> ChildComponentB>>renderContentOn: html
> 
> html anchor
>     callback: [ self showChildComponentA  ];
>     with: 'Show child component A'
> 
> The #showComponentX methods will indirectly communicate  with the
> Parent via announcements, or perhaps via globally accessible object
> like the session and set the bodyComponent in the parent ready for the
> next rendering.
> 
> Both approaches result in the page rendered with the same content.
> Are their any compelling reasons to use one over the other?
> 

-- 
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


More information about the seaside mailing list