Rialto Taglib

Rialto Taglib an implementation of the Rialto Javascript components using a taglib description. Rialto Taglib offers the developers the ability to build UI, by placing the components into a page via JSP tags.

API documentation

See the Taglib documentation

Tutorial

This tutorial will help you to build a simple jsp page using the Rialto taglib For the exemple we will put a label, a text and a button in a page.

Requirements

If not, install a j2EE application server like tomcat Create a root directory in the webapps folder of the server Unzip the rialtoTagLib.zip file in the WEB-INF folder of your root directory. Unzip the Rialto javascript API file in the root directory. Begining First you'll need to have a skeleton of page that include the HTML tag

1<html>
2  <head>
3    <title>My page</title>
4  </head>
5  <body>
6       <div style="left:100px;height:80px;top:40px;position:absolute;width:300px;border:1px solid rgb(120,172,255);" id="divConteiner"/>
7  </body>
8</html>

Add a reference to the TLD You must refer to the rialto.tld to use the taglib in your page.

 1<%@taglib uri="taglib/src/main/resources/META-INF/tlds/rialto.tld" prefix="rialto"%>
 2<html>
 3  <head>
 4     <title>My page</title>
 5  </head>
 6<body>
 7  <div style="left:100px;height:80px;top:40px;position:absolute;width:300px;border:1px solid rgb(120,172,255);" id="divConteiner"/>
 8</body>
 9</html>

Use the differents tags Now we are going to use the tag. The first one you'll need to add is the import tag. It will refere all the javascript and css files that compose the Rialto API. With the 0.24 release of the taglib , don't forget to mention in the pathRialtoEngine attribute the path file containing rialtoEngine

<rialto:import pathRialtoEngine="/rialtoEngine"/>

 1<%@taglib uri="taglib/src/main/resources/META-INF/tlds/rialto.tld" prefix="rialto"%>
 2<html>
 3  <head>
 4    <title>My page</title>
 5  </head>
 6
 7  <rialto:import/>
 8
 9  <body>
10       <div style="left:100px;height:80px;top:40px;position:absolute;width:300px;border:1px solid rgb(120,172,255);" id="divConteiner"/>
11  </body>
12</html>

Then we will use a layout tag that is going to encapsulate our components We have to set 3 attributes

  • the name of the layout (myLayout). The name would become the name of the javascript object representing the layout. So myLayout() is the constructor of the object.
  • the refParentHTML of the layout that indicate the HTML element of the page in which we want to put our components
 1<%@taglib uri="taglib/src/main/resources/META-INF/tlds/rialto.tld" prefix="rialto"%>
 2<html>
 3  <head>
 4    <title>My page</title>
 5  </head>
 6
 7  <rialto:import/>
 8  <rialto:layout name="myLayout"  refParentHTML="document.getElementById('divConteiner')">
 9
10  </rialto:layout>
11 <body>
12       <div style="left:100px;height:80px;top:40px;position:absolute;width:300px;border:1px solid rgb(120,172,255);" id="divConteiner"/>
13 </body>
14</html>

After we add 3 elements using there tag

  • a label
  • a text
  • a button
 1<%@taglib uri="taglib/src/main/resources/META-INF/tlds/rialto.tld" prefix="rialto"%>
 2<html>
 3  <head>
 4    <title>My page</title>
 5  </head>
 6
 7  <rialto:import/>
 8  <rialto:layout name="myLayout"  refParentHTML="document.getElementById('divConteiner')">
 9     <rialto:label name="lib" top="10" left="10" text="login" className="libelleCopy"/>
10     <rialto:text top="10" left="80"/>
11     <rialto:button name="BRECH" top="30" left="200" title="Enter"/>
12  </rialto:layout>
13 <body>
14       <div style="left:100px;height:80px;top:40px;position:absolute;width:300px;border:1px solid rgb(120,172,255);" id="divConteiner"/>
15 </body>
16</html>

Add javascript code The name indicate in the tag is the same that the javascript variable. This is why you have to be carreful to the name you give to your tags. So we can now add javascript code on the component. For exemple we can change the location of the page after a clic on our button. We nee

 1<%@taglib uri="taglib/src/main/resources/META-INF/tlds/rialto.tld" prefix="rialto"%>
 2<html>
 3  <head>
 4    <title>My page</title>
 5  </head>
 6
 7  <rialto:import/>
 8  <rialto:layout name="myLayout"  refParentHTML="document.getElementById('divConteiner')">
 9     <rialto:label name="lib" top="10" left="10" text="login" className="libelleCopy"/>
10     <rialto:text top="10" left="80"/>
11     <rialto:button name="BRECH" top="30" left="200" title="Enter"/>
12
13     BRECH.onclick=function(){
14       window.location="http://rialto.application-servers.com/" 
15     }
16  </rialto:layout>
17 <body>
18        <div style="left:100px;height:80px;top:40px;position:absolute;width:300px;border:1px solid rgb(120,172,255);" id="divConteiner"/>
19 </body>
20</html>

The javascript code can be add directly in the layout tag or between two <SCRIPT> tag in the page. Just pay attention to the range of the variables. Instanciate our javascript components To instanciate The layout you can use the javascript function rialto.loadObject. You have to pass the name of the layout in parameter. The fonction return a variable of the create instance. We can do it using the rialto.onload method

 1<%@taglib uri="taglib/src/main/resources/META-INF/tlds/rialto.tld" prefix="rialto"%>
 2<html>
 3  <head>
 4    <title>My page</title>
 5  </head>
 6
 7  <rialto:import/>
 8  <rialto:layout name="myLayout"  refParentHTML="document.getElementById('divConteiner')">
 9     <rialto:label name="lib" top="10" left="10" text="login" className="libelleCopy"/>
10     <rialto:text top="10" left="80"/>
11     <rialto:button name="BRECH" top="30" left="200" title="Enter"/>
12
13     BRECH.onclick=function(){
14       window.location="http://rialto.application-servers.com/" 
15     }
16  </rialto:layout>
17
18  <script>
19  rialto.onload=function(){
20      var lay=rialto.loadObject("myLayout");
21  }
22  </script>
23  >         
24 <body>
25        <div style="left:100px;height:80px;top:40px;position:absolute;width:300px;border:1px solid rgb(120,172,255);" id="divConteiner"/>
26 </body>
27</html>

Look at the result