Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » JET2 Traversing Trees(How do I use JET2 tags to traverse a tree of unknown depth?)
icon5.gif  JET2 Traversing Trees [message #989177] Wed, 05 December 2012 01:45 Go to next message
Phillip Drew is currently offline Phillip DrewFriend
Messages: 77
Registered: October 2012
Member
So I've got a fairly basic model

Container - can contain 0...* containers, can contain 0...* ViewObjects
ViewObject - Represents an object on a view

Obviously the containers can form a tree of any depth so for example I could have

Container
    (contains)
    - View Object
    - Container
         (contains)
         - ViewObject
         - Container
               (contains)
               - ViewObject


However I need to be able to 'recurse' down that tree structure in my JET2 template without restricting myself to a particular depth (eg. I don't want to create a template that can only look up to 10 levels deep)

Is there an established way to do this in JET2? My experience so far has been using <c:iterate> loops to look at tree structures to a fixed/known depth.

There are some promising looking tags like <c:deepIterate> and <c:visitor> however I can't really tell if they're appropriate or how to use them from the documentation.

Any help you can give me would be much appreciated!
Re: JET2 Traversing Trees [message #989327 is a reply to message #989177] Wed, 05 December 2012 16:19 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Phillip:

I think deepIterate is probably what you want.

Have a look at:

http://wiki.eclipse.org/M2T-JET/Whats_New_in_1.0_%28Galileo%29#Generating_content_from_recursive_structures_is_now_easier

Paul
Re: JET2 Traversing Trees [message #989379 is a reply to message #989327] Wed, 05 December 2012 22:39 Go to previous messageGo to next message
Phillip Drew is currently offline Phillip DrewFriend
Messages: 77
Registered: October 2012
Member
Hi Paul,

Thanks for the response.

I am currently using <c:include> recursively to traverse the tree - are there going to be any serious performance (or other) issues doing it this way?

Thanks

Phillip

[Updated on: Wed, 05 December 2012 22:41]

Report message to a moderator

Re: JET2 Traversing Trees [message #989561 is a reply to message #989379] Thu, 06 December 2012 17:56 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
c:include is fine. JET has used that approach for years.

Just be aware that c:include, be default sees all the variables from its calling context (all variables in JET are global). You can get the effect of a call stack by using the 'passVariables' attribute.

See:

http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.jet.doc%2Freferences%2Ftaglibs%2FcontrolTags%2FincludeTag.html

Paul
Previous Topic:[JET]
Next Topic:JET2 User Regions
Goto Forum:
  


Current Time: Thu Apr 25 17:17:49 GMT 2024

Powered by FUDForum. Page generated in 0.03127 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top