Reference Manual for Gracelets - 2.0.0.RC2SourceForge.net Logo
2.4 - Tutorial : Importing other libraries
If you need to use a Facelet tag library that you have written or that is in a third part library that is not automatically available you can import it very easily. The following line of code shows how to import a library:

Toggle Line Numbers
1 sl = ns."http://somenamespace/taglib" 
Above we are assiging a builder that will represent the tag library that has a namspace called "http://somenamespace/taglib".

One interesting feature with builders is the ability to be able to determine whether the library is really available. When you import a library as above it won't complain if that library does not really exist, in other words, if it has not really been loaded by the Facelets/Gracelets system. You can check the loaded attribute on a builder to find out if it is really available, as in the following example:
Toggle Line Numbers
1 if (sl.loaded) { ... } 
The above code would check to see if the library is actually available. This may not be very useful for view scripts, but is a very nice feature for Gracelet Component Libraries, whose components can choose to have alternate rendering depending on the availability of a facelet tag library.

Using imported libraries

Using these imported libraries/builders is exactly the same as the builders we have seen so far. You simply call the method that is equivalent to the tag name in the library and pass it the map of attributes you want to.