OC,
Here’s what I think you are looking for:
<!-- ParentComponent.wo -->
<html>
<head>
<script>
var a = <wo:str value="$initialValue"/>;
// do NOT use 'a' yet ...
</script>
</head>
<body>
<!-- ChildComponent.wo -->
<wo:if condition="$shouldItBeOverridden">
<script>
a = <wo:str value="$overridingValue"/>;
</script>
</wo:if>
<!-- /ChildComponent.wo -->
<script>
// use 'a' here
// or $( document ).ready( function() { /* use 'a' here */ } );
</script>
</body>
</html>
<!-- /ParentComponent.wo -->
Lemme know if this is what you are looking for.
--
Robert B. Hanviriyapunt
On Feb 5, 2015, at 10:36 PM, OC <[email protected]> wrote:
> On 5. 2. 2015, at 22:38, Samuel Pelletier <[email protected]> wrote:
>
>> The simple fact you care is a bad smell (from Clean Code). By definition, a
>> component should not care about it's parent or childrens, it break the
>> encapsulation principle and component are supposed to manage views only. The
>> only communication between them is via the bindings which are like the
>> public interface of the component.
>
> On 5. 2. 2015, at 23:01, Robert B. Hanviriyapunt <[email protected]>
> wrote:
>
>> 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).
>
> So as to get an immediate response without a need to reload, my standard html
> header contains a javascript, which in some pre-defined intervals polls the
> server and if server says so, the script changes a couple of values in the
> page (marked by appropriate spans).
>
> The trick is that some „plugins“, i.e., components pretty deep in the
> hierarchy and inside of lots of <wo:ifs>, might sometimes need to change the
> poll interval. If the components happen not to be used at all, the script
> runs with the default interval.
>
> My original attempt looked conceptually (leaving out boring details) like
> this:
>
> === code ===
> class MyRootPage extends ERXComponent {
> int autoRefreshRequestDelay
> void awake {
> int
> autoRefreshRequestDelay=ERXProperties.intForKey('DefaultAutoRefreshRequestDelay')
> }
> ...
> }
> class MyPlugin extends ERXComponent {
> void awake {
> MyRootPage root=this
> while (root.parent()) root=root.parent()
>
> root.autoRefreshRequestDelay=ERXProperties.intForKey('SpecialPluginAutoRefreshRequestDelay')
> }
> ...
> }
> === MainPage.html ===
> ... the script here ...
> var refreshDelay=(<wo:str value="$autoRefreshRequestDelay"/>)
> ... other HTML ...
> ===
>
> My idea was that all awakes go first, thus the proper delay would be set
> automatically, based on whether the plugin happens to be in the page or not.
> Then, appendToResponse-time, when the page gets rendered, the JS would get
> the proper value.
>
> Self-evidently couldn't work given the JS gets actually rendered before most
> subcomponents (including the plugins) are awaken.
>
> To solve the problem, I simply moved the JavaScript to the very end of the
> MainPage :) 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.
>
> Well I don't know; perhaps there's a much better and cleaner solution which I
> simply don't see?
>
> Thanks and all the best,
> OC
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]