• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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

 
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
 
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
 
Bartender
Posts: 1845
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!