This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I have written a custom tag that iterates through a vector of strings and lets them be printed to the jsp page. so far I have set vector values by assigning the vector as an attribute to the pagecontext in the jsp and then retrieving the attribute in the custom tag. it works, but it still doesnt look correct to me. Is there a more 'attractive' way to do this, such as passing the vector object as a parameter, attribute or variable to the tag. I have done the same thing using scriptlets and beans already and want to learn how to use tags properly because use of scriptlets seems to be a big no-no. thanks chris
You can pass an object (including a Vector) to a custom tag if you have a mutator that accepts that type. Problem is, you need to use a scriptlet expression to pass it. If you are trying to completely "tagify" your page and remove scriptlets and scriptlet expressions, this may not be acceptable. What's probably making you uncomfortable about the mechanism of placing the object on the page context for use by the tag, is that you have introduced an artificial coupling between the page and the tag, as they have to agree upon the attribute name. And even Martha would agree that that's not a good thing. A compromise that I've used in the past has been to place the object on the page (or other, as appropriate) context, and then pass the name of the attribute as a param to the tag. This way, there are no scriplets or scriptlet expressions involved, and there is minimal coupling of the page and the tag. bear