Clarity

  • 1.  GEL Script : "Subprocedures"?

    Posted Feb 17, 2011 09:50 AM
    I'm writing a slightly complex GEL script, and I find I am repeating some sections of the GEL 'code' a few times in the GEL script that I am going to paste into my Clarity process.

    So my question is;

    Is there the concept of a sub-procedure in GEL scripting, ie I can write a piece of GEL code and call it a number of times within the same overall GEL script?

    (if it helps any, the bit of code that I'm repeating is a "send email" chunk of code around the <gel:email> method)

    (I don't know if I'm phrasing all this right either; should I be looking at the problem from another direction and talking about creating new methods which extend the <gel:email> method?)

    Confused! :wacko:


  • 2.  RE: GEL Script : "Subprocedures"?
    Best Answer

    Posted Feb 17, 2011 10:52 AM
    There are basically three ways to call 'sub-routines' :

    1. Write your own tag. probably a bit overkill.
    2. Put the sub-routine into a separate script and include it several times. Problem with this is that the script has to live in a file on the server somewhere and you have to mess around with hard-coded paths in your script.
    3. Use the jelly:define taglib, not included with standard clarity. Its here : jelly:define I do not understand why this is not included in the standard Clarity distribution, as it really is a gem. It basically allows you to write your own tags using jelly itself, for example:

    <define:taglib uri="foo">
    <define:tag name="bar">
    <gel:out>You passed in : ${var1} and ${id}</gel:out>
    <gel:out>the grand old duke of york, he had ten thousand men</gel:out>
    </define:tag>
    </define:taglib>

    <foo:bar var="test" id="1234" />

    Notice that you can pass in attributes to your tag, in my example 'var' and 'id', and you can use them inside the tag as variables ${var} and ${id}. I'm not going to tell you all it can do, thats what I get paid for :) Besides, its all in the documentation.

    /Mark


  • 3.  RE: GEL Script : "Subprocedures"?

    Posted Feb 17, 2011 10:59 AM
    Excellent thanks: that "define" is the answer I think I was looking for!

    I had poked around in the "documentation" at http://commons.apache.org/jelly/, but I find it all a little "unfriendly" :tongue Its OK if you KNOW what you are looking for (i.e. for reference), but trying to find out which bit you need is a bit of a pain!

    --

    EDIT and yes 'sub-routines' is a much better/more generic term than 'sub-procedures' B)

    Although I think having to install the <jelly:define> into my Clarity environment will actually cause me more (governance/deployment) grief than just duplicating some code so I may just give up... the software engineer in me is not happy with that.