Tinak come with a JSP Tag Library (Taglib) to help write device aware JSP pages. This Taglib is very simple. It provides tags to allow the author to include, exclude and select content based on the requesting device name, or a device profile.
Including & Excluding Content
Tinak uses the ua tag for including and excluding content. The ua tag is is the most important tag in the Tag Library. This is the tag which provides the JSP interface to the device recognition module - Tinak.
The ua tag supports the following attributes:
| Attribute | Description | Required |
|---|---|---|
| match | Defines a comma separated list of device names (or profiles) to match against for the content enclosed within the ua tag. Again, the valid device names are those defined in the device recognition module | Yes |
| dir | Defines a directive in the case of a successful match being made. The supported directives are "add" (or "+") and "remove" (or "-") where the default is "add" i.e. in the case of dir not being defined | No |
Using the ua tag with the match and dir attributes allows the author to include and exclude content based on the requesting device name or profile. The dir attribute need only be defined in the case of a "remove". The "add" value is only defined for completeness.
A more informal definition of the permitted values of the dir attribute might be:
| Value | Description |
|---|---|
| add (or "+") | Only include the enclosed content where the requesting device is named in the match or is a member of a profile named in the match. Exclude for all other devices. |
| remove (or "-") | Only include the enclosed content where the requesting device is NOT named in the match or is NOT a member of a profile named in the match. Include for all other devices. |
Example:
<tinak:ua match="nokia"> <img src="nokia.xxx" /><br/> As a Nokia owner you are entitled to a whole range of new offers... </tinak:ua>
Selecting Content
Where only one of a number of pieces of content is to be included in the output, the author can use the select tag. This tag selects the first match in a series of ua tags. The ua tags can't define a match directive (dir) in this case - they are all interpreted as having an implicit "add" directive.
A good example of where this tag is used is in the selection of an image e.g.:
<tinak:select> <tinak:ua match="image-gif-enabled"> <img src="tinak.gif" /> </tinak:ua> <tinak:ua match="image-jpeg-enabled"> <img src="tinak.jpg" /> </tinak:ua> <tinak:ua match="image-png-enabled"> <img src="tinak.png" /> </tinak:ua> <tinak:ua match="image-wbmp-enabled"> <img src="tinak.wbmp" /> </tinak:ua> <!-- Default... --> <tinak:ua">Tinak</tinak:ua> </tinak:select>
As you can see from the example, the ua tag can be used without a match attribute. This is equivalent to match-all. This can be used to define a default in the select - if nothing matches.
In situations such as the image example above, it would appear to be a good idea to modularise such content selection by putting it in a JSP file of its own and statically including the JSP page where the image is required. This also makes the Tinak tags less intrusive in the core pieces of content. In the image example, the above select block could be put into a JSP page called, for example, image-tinak.jsp e.g.:
<%@ include file="/images/image-tinak.jsp"%>



