aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes nested tag doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "nested tag doubt" Watch "nested tag doubt" New topic
Author

nested tag doubt

dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
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


SCJP-1.5<br />SCWCD-1.4
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4725

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.


A good workman is known by his tools.
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
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

Joined: Feb 05, 2003
Posts: 4725

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: nested tag doubt
 
Similar Threads
Doubt on nested tags
Is this an error or Im not understanding
Nested Tag example in HFSJ
CustomTag - EVAL_BODY_BUFFERED
Stumped !! HFSJ : Page 550 : Q3