Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nested tag doubt

 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The below example is from the HFSJ book, chapter:10, page:539. I wrote both the file. I ran it , it gives me blank page in the output. I did not write TLD. Do I need to write TLD for that? If yes, how to write TLD for nested tag. The book have not mentioned any TLD for nested tag. Can anyone please help me?



-this is a Classic Tag Handler class
-------------------------------------------------------------------------------

<html>
<body>
<mine:nestedlevel>
<mine:nestedlevel>
<mine:nestedlevel />
</mine:nestedlevel>
</mine:nestedlevel>

</body>
</html>

-this is JSP
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you'll need to make a TLD. I remember feeling very intimidated the first time I wrote one but I after I did it I thought "I guess that wasn't so bad" and then I could copy and paste that TLD to make other ones!

You'll also need to reference the tag library in your JSP. You can look at page 542 for that.

You can reference page 467 for writing your TLD, but you'll definitely need to change the values of everything. Luckily, this example you're doing doesn't require you to map any attributes or functions, so your resulting TLD file will be quite small.

By the way, it's great that you're taking the time to try this example. I promise you'll really get a better understanding as a result.
 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Marc, actually I did write one TLD after I did post & I got the result as same as book.
Can you explain how doStartTag() will invoke? I mean it invokes when most outer tag will invoke? And how the nestLevel is "0" first time? In short give me some flow of tag invocation & how doStartTag() will work?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start at the top of your JSP and read through it like a book.

Every time you reach the opening (start) tag of a custom tag, that tag's doStartTag method gets invoked.

The first tag you reach is on the outside of the other tags, so its nesting level will be 0.

Nothing tricky.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic