• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

How to define multiple tag handlers

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I just tried to execute the example(Menu and MenuItem tag handlers) given on the page 543 in HFSJ first editon.

There two tag handlers are given:Menu and MenuItem..
But how to define these tag handlers in Tag Library Descriptor..Should i use seperate TLD for seperate tag handlers or only in one file should i give the both tag handlers..

Any link which provides how to deal with multiple tag handlers is of great help as these things are not explained in HFSJ

Thanks & Regards,
Sudhakar Karnati
 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this link

I think the general convention is one tld file per-prefix.
So say you define multiple tags specifically for menus then you would have one menu.tld and within it you would have definition for say mainMenu tag and subMenu tag and the usage in the jsp would be like menu:mainMenu or menu:subMenu.
If your application is not that big then you can have just a single tld file which would define all the custom tags in your application.

HTH
Shikhar
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Should i use seperate TLD for seperate tag handlers or only in one file should i give the both tag handlers..


You can do both. If you use different TLDs, you'll also have to use different prefixes in your JSP. If you use only one TLD, yoう can use multiple <tag> tags in it.
[ July 09, 2008: Message edited by: Christophe Verre ]
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You can do both. If you use different TLDs, you'll also have to use different prefixes in your JSP. If you use only one TLD, yoう can use multiple <tag> tags in it.



I tried this but not getting the result:

Here is my code:

index.jsp


Simple.tld


Simple1.tld


Menu.java


MenuItem.java


Please tell me what is wrong in the above code..

Thanks & Regards,
Sudhakar Karnati
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With the parent's body content set to "tagdependent", I don't think that the inner tags will be evaluated. But there's a bigger problem : Menu's doEndTag is not spelled properly. doEndtag -> doEndTag
[ July 10, 2008: Message edited by: Christophe Verre ]
 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change:
<short-name>simple</short-name> in simple.tld
to
[bhort-name>Menu</short-name> [/b]
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please ignore my above post and consider this:
Change:
<short-name>simple</short-name> in simple.tld
to
<short-name>Menu</short-name>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anand, the short-name has no influence on the way the tag will be used.
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

With the parent's body content set to "tagdependent", I don't think that the inner tags will be evaluated. But there's a bigger problem : Menu's doEndTag is not spelled properly. doEndtag -> doEndTag



I made the aove changes(tagdependent to scriptless) and it is working fine..
Thanks for your quick replies..

Thanks & Regards,
Sudhakar Karnati
 
Anand Bhatt
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Christophe , I was confused <short-name> with <name>.
You are correct.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic