SourceForge.net Logo

Example 5: Hello World Revisited

In previous examples you've seen Taconite actions with just one node identifier into the contextNodeId attribute.
However, Taconite let you also specify a comma separated list of node identifiers: Taconite will select all elements whose identifier is in the list.

It's absolutely straightforward.

Here is the XHTML page:

01 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
02  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
03 
04 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
05     <head>
06         <title>Taconite Example</title>
07         <script type="text/javascript" src="/taconite-examples/js/taconite-client.js"></script>
08         <script type="text/javascript" src="/taconite-examples/js/taconite-parser.js"></script>
09         
10         <script type="text/javascript">
11             function doHelloWorld(url) {
12                 var ajaxRequest = new AjaxRequest(url); //Create AjaxRequest object
13                 ajaxRequest.sendRequest();  //Send the request
14             }
15         </script>
16     </head>
17     <body>
18         <br/>
19         <br/>
20         <a href="javascript:doHelloWorld('example1-all.jsp');">Hello World</a>
21
22         <br/><br/>
23         <div id="helloWorldContainer1"></div>
24         <div id="helloWorldContainer2"></div>
25
26     </body>
27 </html>
                    

Note the two DIV containers at Line 23 and 24.

Now, here is the Taconite stuff:

01 <%@page contentType="text/xml"%>
02 
03 <taconite-root xml:space="preserve">
04  
05     <taconite-append-as-children contextNodeID="helloWorldContainer1, helloWorldContainer2">
06     
07        <div style="font-weight:bold;color:orange;">
08            Taconite says: Hello World!!!
09        </div>
10         
11     </taconite-append-as-children>
12
13 </taconite-root>
                    

As you can see at Line 5, the contextNodeID has two comma separated identifiers: helloWorldContainer1 and helloWorldContainer2, the identifiers of the DIV elements above!

Summary

Taconite is able to match (and select) more elements by simply specifying more identifiers into the contextNodeID attribute.
However, it's just the beginning ... go and take a look at Taconite Match Modes!