[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    [jira] Commented: (JELLY-74) Scope inheritence is not being obeyed
From:       jira () codehaus ! org
Date:       2003-09-30 16:39:16
[Download RAW message or body]

The following comment has been added to this issue:

     Author: Scott Howlett
    Created: Tue, 30 Sep 2003 11:37 AM
       Body:
Since this problem has been partially fixed, I have opened another issue that is \
                specific to the Jexl expression problem.
---------------------------------------------------------------------
View the issue:

  http://jira.codehaus.org/secure/ViewIssue.jspa?key=JELLY-74


Here is an overview of the issue:
---------------------------------------------------------------------
        Key: JELLY-74
    Summary: Scope inheritence is not being obeyed
       Type: Bug

     Status: Closed
   Priority: Major
 Resolution: FIXED

 Time Spent: Unknown
  Remaining: Unknown

    Project: jelly

   Assignee: 
   Reporter: Scott Howlett

    Created: Fri, 22 Aug 2003 9:35 AM
    Updated: Wed, 3 Sep 2003 8:38 PM

Description:
Given these scripts:

foo.jelly:

<?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core">
    <j:set var="test" value="goofy"/>
    <j:import inherit="false" uri="bar.jelly"/>
</j:jelly>

bar.jelly:

<j:jelly xmlns:j="jelly:core">
    ${test}
</j:jelly>

When I execute foo.jelly, the expression in bar.jelly finds the value of test even \
though inheritence is false.

This is because the JellyMap inside the JexlExpression gets variables like this:

    public Object get(Object key) {
        return context.findVariable( (String) key );
    }

where findVariable will find the variable in any enclosing scope regardless of \
inheritence.

The fix ought to be to change it to use getVariable(). Unfortunately, \
JellyContext.getVariable() itself doesn't obey scope inheritence:

    public Object getVariable(String name) {
        Object value = variables.get(name);

        if ( value == null && isInherit() ) {
            JellyContext parent = getParent();
            if (parent != null) {                
                value = parent.findVariable( name );
            }
        }

        return value;
    }

The context obeys its own inheritence rule but ignores any inheritence rule set by \
its parent. The fix for this would be to change parentfindVariable(...) to \
parent.getVariable(...)



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic