Custom JSP taglib. Lets you proceed templates in your JSP pages. Body tag translate lets you replace user defined keys in own body with some predefined values. For example: <%@ taglib uri="taglib.tld" prefix="tr" %> <!-- create dictionary --> <tr:dictionary id="A"> <tr:add key="$1">first var</tr:add> <tr:add key="@2">second var</tr:add> </tr:dictionary> <!-- transform text -->
Here substring $1 will be replaced with value first var and substring @2 will be replaced with value second var Dictionary is just a set of pairs <some key, some value>. Any dictionary is a page scope, request scope, session scope or application scope variable. Name for this variable as well as a scope both are parameters for tag dictionary. You can directly define your keys and values (see above) or import them from some Hashtable (HashMap). For example: <% java.util.Hashtable t=new java.util.Hashtable(); ... <%> <!-- create session scope dictionary and import data --> <tr:dictionary id="A" scope="session" source="<%=t%>" /> Tag translate uses by default the following delimiters within the text for detecting the possible replacements: \t\r\n<>,.;:-()[]{}= (first is a space). With attribute ignoreDelimiter="true" tag will replace keys within the text "as is", so you can for example use keys with spaces etc. Tags are: dictionary Body tag. Creates dictionary. Parameters are: 1) id Describes a name for variable
add Body tag. Adds a pair to dictionary. Tag's body describes value. Parameters are: 1) key Describes a key translate Body tag. Transforms own body according to the given dictionary. Parameters are: 1) id Describes an id for your dictionary
for downloading: Library: transtag.jar Description: taglib.tld See also Coldtags suite - the largest collection of custom JSP tags.
|
Also in Coldtags:
|