On Wed, Aug 26, 2009 at 10:04 PM, Branden Visser<[email protected]> wrote:
> If I include a script that has similarly named variables as my parent
> script, I *think* the common variables in the parent script are being wiped
> out.
>
> For example:
>
> <%
>  var foo = currentNode.getNode('foo');
>
>  sling.include('/my/content/foobar.html');
>
>  var bar = foo.getNode('bar');
> %>
>
> If the script mapped to /my/content/foobar.html contains a variable 'foo',
> then the last statement will give an error, because foo is now undefined in
> the parent.
>
> I haven't had a chance to create a definite test case to verify it yet, but
> multiple observations of my variables being mysteriously wiped out suggest
> this is what is happening.
>
> Is this to be expected?

AFAIK both esp files are executed completely separately, since the
sling include starts a whole new (include) request processing step -
for example, the code that gets executed for /my/content/foobar.html
could be a Java servlet. Therefore it is unlikely a javascript
variable conflict.

It could be that the node under "foo" gets removed which might lead
into an exception (wild guess). Or maybe that the javascript-to-java
binding makes problems in certain cases (which would rather explain an
"undefined var" error). Nevertheless, I think you should debug that
further, because I think it needs more information to pin-point the
real issue.

Regards,
Alex

-- 
Alexander Klimetschek
[email protected]

Reply via email to