aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes How to define multiple tag handlers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "How to define multiple tag handlers" Watch "How to define multiple tag handlers" New topic
Author

How to define multiple tag handlers

sudhakar karnati
Ranch Hand

Joined: May 03, 2007
Posts: 93
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
Shikhar Madhok
Ranch Hand

Joined: Dec 18, 2006
Posts: 95
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


He who asks a question is a fool for five minutes; he who does not ask a question remains a fool forever - Chinese proverb
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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 ]

[My Blog]
All roads lead to JavaRanch
sudhakar karnati
Ranch Hand

Joined: May 03, 2007
Posts: 93
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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 ]
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
Change:
<short-name>simple</short-name> in simple.tld
to
[bhort-name>Menu</short-name> [/b]
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

Anand, the short-name has no influence on the way the tag will be used.
sudhakar karnati
Ranch Hand

Joined: May 03, 2007
Posts: 93
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

Joined: May 30, 2007
Posts: 189
Thanks Christophe , I was confused <short-name> with <name>.
You are correct.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to define multiple tag handlers
 
Similar Threads
to open an exe within the internalframe
Nested bean: doEngTag() not invoked
simple web browser in java
Exam Gotchas?
Classic Tag Handlers - Are they thread safe?