commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guo, Jiaqi" <>
Subject Re: [jelly] Can I get the unique ID for current TagScript
Date Thu, 04 Aug 2005 15:47:44 GMT
Hi Hans,

Sorry for late response.

Here's scenario where the same Script runs again and again with 
different context. So I keep the Script object and run it with fresh new 
JellyContexts which have the same parent JellyContext so that I don't 
need to register all the home made tag libraries repeatedly. But 
sometimes, the logic executed in MyTag doesn't depend on context at all. 
Give you an example which is not the exact one that I'm working on.

<mylib:Courses var="allCourses"> <!--Create a list variable-->
    <mylib:CourseOperationSystem/> <!-- Add courses to allCourse 
variable one by one-->
    ... another 100 courses...
<echo>Student ${student} want to take all courses</echo>
<!--student comes from context, it could be different every time the 
script runs -->
<mylib:TakeCourses student="${student}" courses="${allCourses}"/>
JellyContext rootContext = new JellyContext();
rootContext.registerTagLibrary("my taglib uri", new MyTagLibrary());
Script script = rootContext.compileScript(theScriptFile);

JellyContext jc = new JellyContext(rootContext);
jc.setVariable("student", "John");, output);

jc = new JellyContext(rootContext);
jc.setVariable("student", "Tommy");, output);


If I can assume that the creating each course doesn't need context, I 
actually know the full course list after the first time this script 
runs. If I can cache the course list somewhere in TagScript, I don't 
need to create 103 courses again and again. Because <Courses> tag can be 
used somewhere else in this script, I need a key to identify this guy. I 
can't simply save the list in CourseTag class because tag class is 
transient. Another option is forcing script writer to put an id 
attribute. But internal key makes it look simpler.

So my question is can I get unique ID for TagScript where I'm in 
corresponding Tag class.

Let me know if I didn't explain the question clearly. Thanks for your time.


Hans Gilde wrote:

>Well, this doesn't sound like a good thing to be doing. Could you describe
>the purpose, maybe there is another approach?
>-----Original Message-----
>From: Guo, Jiaqi [] 
>Sent: Tuesday, August 02, 2005 2:06 PM
>Subject: [jelly] Can I get the unique ID for current TagScript
>When I'm in a home-made Tag class, can I get a unique identifier for the 
>current TagScript? So that next time the same tag in the same script is 
>invoked, I know it's the same thing. Therefore, if I want to cache 
>something I can do it.
>I can't take MyTag.hashCode() because Tag is transient object in my 
>case. Can I do MyTag.getBody().hashCode()? It doesn't sound well for 
>those tags without body.
>Any solution for it? Thanks.
>To unsubscribe, e-mail:
>For additional commands, e-mail:
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message