[Logo] Mentawai Recipes
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Moderation Log] Moderation Log   [Register] Register / 
[Login] Login 
Creating your own display tags  XML
Forum Index » Official Recipes
Author Message

Joined: 10/01/2008 08:20:15
Messages: 39

Let's say for example that you want a tag that will print the number of friends of an user. If he has only one friend, the word "friend" will be in the singular form. If he has more than one friend, then the word is "friends". And if he has no friends at all, then you will print a friendly message saying nobody likes him (or just something like "You have no friends!").

Notice that because you extended from PrintTag, you have access to the following protected instance variables:

Now to use your tag, you need a TLD file. This is a Servlet API requirement and there's nothing we can do about this file, so save the XML below in a file inside the /WEB-INF/tld directory, for example taglib.tld:

Now in your JSP page, you can do this:

Forum Index » Official Recipes
Go to:   
Powered by JForum 2.1.8 © JForum Team