• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create a custom tag similar to <c:forEach/> tag?

 
varun maheshwari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I would like to create a custom tag which works similar to <c:forEach/> tag i.e

<c:forEach var = "movie" items = "${collection}>
${movie}
</c:forEach>

I would want to create the similar behaviour(as above) in my own custom Tag.Morever I would like to use the doStartTag() and doEndTag() and doAfterBody() methods while creating custom Tag.
Please Post the code for the for the same.

Waiting for your response!!!

Varun Maheshwari
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
varun maheshwari wrote:
Please Post the code for the for the same.

Welcome to the Ranch, but that's no quite how things work. Please post your code, and you will get some help with it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. What would your new tag do that you cannot do with <c:forEach>?
 
varun maheshwari
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir

I would definitely paste my code here ,if I have some clue regarding how to approach to create such a tag.

The code that I have pasted in above post ,I want only that behaviour to replicate in my custom Tag.

Sir ,Please let me know how should I approach to create such a Tag.I have searched on google but no where such a code is written.

Any help would be appreciated


Varun Maheshwari
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to implement the javax.servlet.tagext.IterationTag interface
A good starting point is to extend the TagSupport class in the same package.




 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!