Re: R/R loop 101: how to trigger a subcomponent method before appendToResponse?
Re: R/R loop 101: how to trigger a subcomponent method before appendToResponse?
- Subject: Re: R/R loop 101: how to trigger a subcomponent method before appendToResponse?
- From: OC <email@hidden>
- Date: Sat, 07 Feb 2015 03:28:45 +0100
Samuel,
> I see, you mixed the server processing with the client side processing in the same timeline.
am I? I might well be overlooking something of importance, and I has been wrong many times, but I don't think so. There's no problem with the actual client-side processing; my problem was that the client-side processor has been set improperly.
Had there been a simple wo:str displayed in the page instead of part of the javascript, the problem would be exactly the same -- the page would sport a wrong value.
To recap,
(a) I need that value to differ from default in case a subcomponent is used in the page
(b) I can't see better way to do that than to have a default value stored in root component, overwritten by subcomponent (of course not ever overwritten if the subcomponent happens not to be used)
(c) my problem was that awake can't be used for that, since subcomponents get awaken during appendToResponse -- namely, after the root component might have rendered the value into the page already.
I did not really find any solution; rather worked around the problem by moving the value to the end of the page, ensuring thus all the subcomponents are awaken (and rendered, too) before the value is used.
> If you want to start some JS process, you can add the script inline at the end of the document
Precisely -- as I wrote, “For some reason originally I lived under a misconception that all javascripts must be at the page header; of course they need not, hell knows where I got that dumb idea from.” :)
Thanks,
OC
On 6. 2. 2015, at 16:20, Samuel Pelletier <email@hidden> wrote:
> OC,
>
> I see, you mixed the server processing with the client side processing in the same timeline.
>
> All server processing is done when the client (browser) receive the first byte of data. All the Javascript code execution is defined by the browser but is independant of the server side except if you are using Ajax components that do lazy loads or during Ajax refresh. In these cases, there is a completely new and independent RR loop involved for each request.
>
> If you want to start some JS process, you can add the script inline at the end of the document of register an unload function that will be called after all DOM nodes are complete and ready to display. During Ajax Refresh, the unload handler is not called.
>
> You need to think the Javascript part as a completely different application that run on it's own schedule.
>
> Samuel
>
>
>> Le 2015-02-05 à 17:01, Robert B. Hanviriyapunt <email@hidden> a écrit :
>>
>> I can’t imagine what “something reasonable” would be that would need to fire in a subcomponent before the start of the appendToResponse (assuming that the component structure is a new structure and not the same as the one that might have previously fired takeValuesFromRequest).
>>
>> Can you give more detail?
>>
>> IMHO, I think the operation could either be better placed out of the subcomponent, or, as I believe some framework components have done, insert into (or modify) the current (incomplete) response html (like header script tags) during the subcomponent’s appendToResponse.
>>
>> --
>> Robert B. Hanviriyapunt
>>
>>> On Feb 5, 2015, at 8:58 AM, OC <email@hidden> wrote:
>>>
>>>> Hello there,
>>>>
>>>> looks like not even after all those years I can properly wrap my head around the R/R loop. I sort of thought all (sub)components get awake first; (then other methods not important here) and then all of them get appendToResponse.
>>>>
>>>> Nope. After my code behaved weirdly, I've added logging to both awake and appendToResponse, and with some surprise found they are in fact interspersed like this:
>>>>
>>>> ===
>>>> - AWAKE DFEOForm@1460074866 IN null@null
>>>> - APPEND-RESPONSE DFEOForm@1460074866 IN null@null
>>>> - AWAKE lstr@911219867 IN DFEOForm@1460074866
>>>> - APPEND-RESPONSE lstr@911219867 IN DFEOForm@1460074866
>>>> - AWAKE SharedHeader@1055406501 IN DFEOForm@1460074866
>>>> - APPEND-RESPONSE SharedHeader@1055406501 IN DFEOForm@1460074866
>>>> - AWAKE lstr@911219867 IN SharedHeader@1055406501
>>>> - APPEND-RESPONSE lstr@911219867 IN SharedHeader@1055406501
>>>> ...
>>>> ===
>>>>
>>>> Darn.
>>>>
>>>> I need to allow my subcomponent to do something reasonable before the root page appendToResponse starts.
>>>>
>>>> How could one achieve that?
>>>>
>>>> Thanks a lot,
>>>> OC
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden