Cernunnos Manual


${js()}

Description:

Returns the value of the specified JavaScript EXPRESSION.

Reagents:

Name XPath Description Reagent Type Expected Type Required
CACHE @cache A shared Map to cache items in. The default is the value of the 'Attributes.CACHE' request attribute. PHRASE java.util.Map No
CACHE_MODEL @cache-model Specify either NONE, ONE, or ALL. PHRASE java.lang.String No
EXPRESSION descendant-or-self::text() Script expression to evaluate. PHRASE java.lang.String Yes

Examples:

Creates an array of three URLs in JavaScript, then computes a checksum value ten times for one of the URLs in the array (distributed evenly) using a pool of five threads, writing the current count and checksum value to the console each time:

 
       
        <js> 
          <script>var urls = ['http://www.google.com/', 'http://www.amazon.com/', 'http://www.yahoo.com/']; ScriptAttributes.RESPONSE.setAttribute('urls', urls);</script>  
          <subtasks> 
            <thread-pool threads="5"> 
              <for-each attribute-name="num" items="${groovy([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])}"> 
                <concurrent> 
                  <echo-ln>${num}=${checksum(${js(urls[num % 3])})}</echo-ln> 
                </concurrent> 
              </for-each> 
            </thread-pool> 
          </subtasks> 
        </js>