• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom Tag Question

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to be able to create reusable components for a page. For example a component that displays name and address information that i would be able to place on different pages without having to code the same thing on multiple pages. Can I do this with a custom tag? A simple example or link to an example would be appreciated. Thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can I do this with a custom tag?



Absolutely.

You didn't mention how the address data is making its way to the page, so I will assume you are using a modern Model 2 design.

Let's say that your servlet controller is placing an object of type Address that holds your address data onto the request as a scoped variable named "billingAddress", and another named "shippingAddress".

You could write a custom tag along the lines of:



which will spit out the approriate HTML-formatted data according to what it finds in the scoped variable identified by the "data" attribute.
 
reply
    Bookmark Topic Watch Topic
  • New Topic