You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org> on 2004/11/25 16:49:18 UTC
[jira] Créée: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
add 'public JellyContext newEmptyJellyContext()' to JellyContext
----------------------------------------------------------------
Key: JELLY-167
URL: http://nagoya.apache.org/jira/browse/JELLY-167
Project: jelly
Type: Wish
Components: core / taglib.core
Versions: 1.0-beta-5
Reporter: Marc DeXeT
method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
This constructor copies parent properties AND parent variables.
To create variables quenched context, you have to clear variables or to set inherit to false.
I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://nagoya.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57961 ]
Marc DeXeT commented on JELLY-167:
----------------------------------
Hans Gilde said :
> Could you give an example of an existing piece of code that would be improved?
I have done a lot a thing based upon isolated context concept, as tags which execute their body according to external parameters, it's a tricky thing to modularize script, act as local variables in function (or method to stay object) :
(see http://issues.apache.org/jira/browse/JELLY-193 )
They're looking like :
<code>
public void doTag(XMLOutput output) throws ... {
(...) //- check var, attributes and so on...
JellyContext innerContext = context.newEmptyJellyContext();
for (int i = 0; i < innerVarNames.length;i++) {
innerContext.setVariable(innerVarNames[i],context.getVariable(externVarNames[i]);
}
getBody().run(innerContext,output);
context.setVariable(result, this.result);
}
public void addReturn(Object value){
this.return = value;
}
</code>
This way, you can resolve variable names collision, and for very big script as I have, collision it's a real problem !
Yesterday, tag caching asside, just doing :
<code>
JellyContext innerContext = new JellyContext();
</code>
was enough.
But with Paul new Tag caching feature, you have to set innerContext current context child to be sure to get the real ancestor and not a created one.
If you put in the first tag body a child tag like this :
<code>
public void doAction(XMLOutput output) throws ... {
tag = (CallableTag) findAncestorWithClass(CallableTag.class);
if ( tag == null ) {
throw new JellyTagException("Must be nested in CallableTag");
}
tag.addReturn( value );
}
<code>
You have to be sure It's his real ancestor.
This is an example, but I have also a lot modular features to use external script without name collision, as you can call a method without local and member variable collision.
> Are you suggesting getting rid of inherit and export?
No no, no thing so radical, may be ths method name would be "newEmptyChildContext()".
I'am thinking about is :
public JellyContext newEmptyChildContext() {
JellyContext answer = this.newJellyCotext();
answer.clearVariable();
answer.setInherit(false);
anwser.setVariable("systemScope", this.getVariable("systemScope");
return answer;
}
It pretty easy to put in unit test :
public final void testEmptyChildContext() {
JellyContext context = new JellyContext();
context.setVariable("externalVar","external");
JellyContext emptyChild = context.newEmptyChildContext();
// Child and parent are really child and parent.
assertSame(context, emptyChild.getParent());
// Child doesn't see parent var.
assertNull( emptyChild.getVariable( "externalVar") ) ;
emptyChild.setVariable("internVar","intern");
// Parent doesn't see child var.
assertNull( context .getVariable( "externalVar") ) ;
}
Remember that isolated context can be a response to var name collision, it's not a fantasy, it could be usefull and I think to define over several projects same jelly subclass to get the same feature it's not clever (and tiring for me :) ).
It could be a little improvement for now, but it could be very used (in my opinion) if this feature is part of core API.
Well, it's just my point of view, but I believe in it :)
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Hans Gilde (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57976 ]
Hans Gilde commented on JELLY-167:
----------------------------------
I haven't read over your function tag patch yet, maybe that'll help me understand.
>From your unit test, it seems like you want to create a new JellyContext that's blank but contains the parent's tag cache but no variables. Is that right?
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
> Attachments: patch.function.2.txt
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57979 ]
Marc DeXeT commented on JELLY-167:
----------------------------------
Hans said :
> From your unit test, it seems like you want to create a new JellyContext that's blank but contains the parent's tag cache but no variables. Is that right?
That's it !
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
> Attachments: patch.function.2.txt
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Hans Gilde (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57980 ]
Hans Gilde commented on JELLY-167:
----------------------------------
I completely agree that we should pass down the ClassLoader, but I think that this should be added to the constructor "JellyContext(JellyContext parent)".
I'm not sure about the TagCache, though. Do you have an example where you need to inherit the tag cache?
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
> Attachments: patch.function.2.txt
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57965 ]
Marc DeXeT commented on JELLY-167:
----------------------------------
Sorry, it's the very right issue, but for Hans, it's a good example of what I mean. :)
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
> Attachments: patch.function.2.txt
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Hans Gilde (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57978 ]
Hans Gilde commented on JELLY-167:
----------------------------------
And, when would one use newEmptyJellyContext() as opposed to newJellyContext()?
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
> Attachments: patch.function.2.txt
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Updated: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=history ]
Marc DeXeT updated JELLY-167:
-----------------------------
Attachment: patch.function.2.txt
new version RC2 compatible.
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
> Attachments: patch.function.2.txt
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Hans Gilde (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57960 ]
Hans Gilde commented on JELLY-167:
----------------------------------
Could you give an example of an existing piece of code that would be improved?
Are you suggesting getting rid of inherit and export?
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Hans Gilde (JIRA)" <co...@jakarta.apache.org>.
[ http://nagoya.apache.org/jira/browse/JELLY-167?page=comments#action_55940 ]
Hans Gilde commented on JELLY-167:
----------------------------------
newJellyContext exists so that you can override it. The idea is that a subclass Of JellyContext might want to implement certain behavior when creating a "child" context or a context to run in another thread.
I'm not in favor of adding this method to JellyContext because it's not used by the core Jelly API.
If you want to copy a context in a particular way, why not just create a new static method for yourself (outside of the Jelly API):
public static JellyContext cloneContext(JellyContext cloneMe)
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://nagoya.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://nagoya.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57953 ]
Marc DeXeT commented on JELLY-167:
----------------------------------
Hans Gilde said :
> I'm not in favor of adding this method to JellyContext
> because it's not used by the core Jelly API.
> If you want to copy a context in a particular way,
> why not just create a new static method for yourself (outside of the Jelly API):
I'm sorry but JellyContext is frequently updated and theses modifications could have great consequences in any improvements.
This new static method, although not used by core API (yet ?) would guarantee a constant behavior as newJellyContext does. It's the same, insuring all others core features (tag caching, class loading and so on) are inherit BUT the var map.
Yesterday, just do JellyContext myIsolatedContext = new JellyContext() was enough, but now you have to clearVariables and setInherit(true). And tomorrow there would be another change to do the same way.
Rather than subclassing another time JellyContext, in my point of view make sure of an atomic behavior ( as newJellyContext is) could be a little for core and great for a recurrent need.
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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
[jira] Commented: (JELLY-167) add 'public JellyContext newEmptyJellyContext()' to JellyContext
Posted by "Marc DeXeT (JIRA)" <co...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/JELLY-167?page=comments#action_57993 ]
Marc DeXeT commented on JELLY-167:
----------------------------------
Hans Gilde said
> I'm not sure about the TagCache, though. Do you have an example where you need to inherit the tag cache?
Sure. If you take a look to my function tag library ( http://issues.apache.org/jira/browse/JELLY-193 ), you could see that this tag assign to a context var his body :
+ /**
+ * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
+ */
+ public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
+ if ( getVar() == null ) {
+ throw new MissingAttributeException("var");
+ }
+
+ context.setVariable(getVar(),this);
+ }
and this body is run later as in JSL tag library by a CallTag in Call method
+ /**
+ * @see org.apache.commons.jelly.tags.util.CallableTag#call()
+ */
+ public List call(List arguments,XMLOutput output) throws MissingAttributeException, JellyTagException {
+
+ returnList = new ArrayList();
+
+ innerContext = new IsolatedJellyContext(context);
+
+ transfertArgToContext(arguments);
+ try {
+ getBody().run(innerContext,output);
+ } catch( Exception e ) {
+ if ( ! (e instanceof ReturnException) ) {
+ throw new JellyTagException(e);
+ }
+ }
+ return returnList;
+ }
In the first tag body (FunctionTag), there's a ReturnTag which populate the Function return values list by searching his ancestor :
+ protected void doAction(XMLOutput output) throws MissingAttributeException,
+ JellyTagException {
+
+ if ( tag == null ) {
+ tag = (CallableTag) findAncestorWithClass(CallableTag.class);
+ }
+ if ( tag == null ) {
+ throw new JellyTagException("Must be nested in CallableTag implementator");
+ }
+
+ if ( getValue() != null ) {
+ tag.addReturn( getValue());
+ } else {
+ invokeBody(output);
+ }
+ }
So you have this kind of script :
<function var="myFunc"> // put his body as var
(... body not executed on doTag(XmlOutput) but Call(List arguments,XMLOutput output)...)
<return/>
// - which will search his ancestor (so uses tag cache).
</function>
<call function="${myFunc}"/>
If you don't use _current context_ in FunctionTag Call(List arguments,XMLOutput output)...), but a _new_ context the ResultTag will search his ancestor in a empty tag cache, will don't find his ancestor :
(JellyContext)
/** @return the tag associated to the given TagScript for the current run.
*/
public Tag getTagOfTagScript(TagScript script) {
if( script == null )
return null;
Tag tag = (Tag) tagHolderMap.get(script);
if( tag == null && getParent() != null) {
return getParent().getTagOfTagScript(script);
} else {
return tag;
}
and so create a new tag : returnList will be not populated and Feature will fail!
If you want to test, apply patch http://issues.apache.org/jira/secure/attachment/18710/patch.functionRC_.2.txt
test, then, change in FunctionTag
+ /**
+ * @see org.apache.commons.jelly.tags.util.CallableTag#call()
+ */
+ public List call(List arguments,XMLOutput output) throws MissingAttributeException, JellyTagException {
+
+ returnList = new ArrayList();
+
+ innerContext = new IsolatedJellyContext(context);
+
+ transfertArgToContext(arguments);
+ try {
+ getBody().run(innerContext,output);
+ } catch( Exception e ) {
+ if ( ! (e instanceof ReturnException) ) {
+ throw new JellyTagException(e);
+ }
+ }
+ return returnList;
+ }
by
+ /**
+ * @see org.apache.commons.jelly.tags.util.CallableTag#call()
+ */
+ public List call(List arguments,XMLOutput output) throws MissingAttributeException, JellyTagException {
+
+ returnList = new ArrayList();
///////////// change here ///////////////////
+ innerContext = new JellyContext();
///////////// change here ///////////////////
+
+ transfertArgToContext(arguments);
+ try {
+ getBody().run(innerContext,output);
+ } catch( Exception e ) {
+ if ( ! (e instanceof ReturnException) ) {
+ throw new JellyTagException(e);
+ }
+ }
+ return returnList;
+ }
> add 'public JellyContext newEmptyJellyContext()' to JellyContext
> ----------------------------------------------------------------
>
> Key: JELLY-167
> URL: http://issues.apache.org/jira/browse/JELLY-167
> Project: jelly
> Type: Wish
> Components: core / taglib.core
> Versions: 1.0-beta-5
> Reporter: Marc DeXeT
> Attachments: patch.function.2.txt
>
> method 'public JellyContext newJellyContext()' uses 'public JellyContext(JellyContext parent)'.
> This constructor copies parent properties AND parent variables.
> To create variables quenched context, you have to clear variables or to set inherit to false.
> I wish to have a new method 'public JellyContext newEmptyJellyContext()' which copies all root context properties (as tag caching) but DOESN'T copy variables map.
> Even if you could do the same with inherit or variable map clearing or other methods, it would be more meaningful to use a assigned method
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/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