Custom Tag Libraries : architecture and reasons to use
I am a fairly green Java developer. I have 18 years of overall development experience but only about 1.5 years of Java, and only about that in CQ5. I have taken both the developer and advanced developer courses from Adobe.
I like the idea of a using custom tag library in my CQ projects because I can see how they would improve testability, and code re-use, among other things. However, being fairly new to both Java and CQ5 I don't have a good grasp on exactly what types components would be ideal candidates for a custom tag library, and what an "ideal" overall architecture would be.
So in my cq workspace I have 4 projects:
- "commons" bundle - shared utility classes, mostly static ones. No business logic.
- "core" bundle - contains services, servlets, models, listeners, and whatever business logic the write in Java classes.
- taglib bundle - just what it sounds like
- "UI" or "content" package for the component jsp files, /etc/designs, etc.
So here are my questions:
- How specific or generic do I make the output of custom tags?
- Does everything go into the tag, i.e. html, javascript and all?
- What is the best way to write Unit tests for a custom tag?
- What is the best programming pattern to use for the relationship between the tags and the business logic code?
- How does the use of services and servlets fit with custom tag development?
Thanks in advance,
David T Nelson