introduction | taakStatements | data types | expressions | built-in functions
about
taakServlet
taakScript
raves
 
 
 

Introduction

Taak scripts may invoke user defined functions or user-defined functions. Taak has built-in functions for manipulating strings, lists, and JDOM objects.


Servlet Functions

A Taak script may redirect or forward a request to another URL using the redirect or forward functions.

Function Description Examples
redirect Redirect the request to another URL. redirect("http://www.aol.com");
forward Forward the request to another URL. forward("foo.htm");

 

JDOM Functions

A taakScript execution context may contain a JDOM document. The document is defined as the variable DOCUMENT. A JDOM document contains Elements. An Element has attributes, text, and may contain children Elements. The attribute most often used is the id attribute. The id attribute is used to identify Elements that the script will manipulate. The ids are unique within the document. No two ids in a document can be the same. An easy way to get the Element with a specific id is to use the function getElementById() and pass the DOCUMENT and id as arguments. The other attribute that has a special use is the class attribute. All elements with a class attribute that contains the word "mockup" are automatically removed before processing is done. The specific mockup class can be changed in the taak-config.xml file.

Full list of JDOM functions:

Function Description Examples
getRootElement Returns the root element of a document. getRootElement(DOCUMENT);
getElementById Returns a descendant element with the specified id. The first argument may be a document or an element. getElementById(DOCUMENT, "x");
getElementById(ele, "x");
getElementByName Returns the first descendant element if textual order with the specified tag name. getElementByName(DOCUMENT, "x");
getElementByIndex Returns the nth child indexed from 0 of an element. getElementByIndex(e, 0);
getParent Returns the parent element. getParent(e);
cloneElement Return a deep clone of an element but do not attach the clone to the parent of the original. cloneElement(e);
copyElement Return a deep clone of an element and add it to the parent of the original. copyElement(e);
removeElement Remove an element and all its descendants. removeElement(e);
removeChildren Remove all descendants of an element. removeChildren(e);
getText Returns the text of an element. getText(e);
setText Set the text of an element. setText(e, "foobar");
getAttribute Returns the attribute value of an element. getAttribute(e, "href");
setAttribute Sets the attribute value of an element. setAttribute(e, "href", "foo.htm");
removeAttribute Remove the attribute of an element. domRemoveAttribute(e, "href");
removeIds Remove all id attributes from an element and its descendants. domRemoveIds(e);