Luis Cornide Arce wrote: > Hi List!! > > I'm developing some tags to internationalize my JSP pages (yes, I know > that Struts has done that already, but I'm trying to do it by my own) > I have one tag to retrieve a message by specifiying its key, and inside > of this tag I can write other to parametrize the message (doing a > substitution of a pattern by the value given), an example > <mytag:AppMessage id='index.welcome'> > <mytag:Param value='Hi world' /> > </mytag:AppMessage> > > My problem is that the inner tag is completely ignored. The class that > implements the tag AppMessage extends BodyTagSupport and the methos > doStartTag() returns EVAL_BODY_BUFFERED, is this correct? anybody knows > what can be the error? > > Thanks in advance,
Implementing the BodyTag interface and returning EVAL_BODY_BUFFERED is onlye needed for a tag handler that *reads* its body. In the example above, all you want is to *evaluate* the body, so you only need to implement the Tag interface (e.g. by extending TagSupport) and return EVAL_BODY_INCLUDE from doStartTag() in your AppMessage tag handler. This tells the container to invoke the Param tag handler for the nested action. In the Param tag handler, you must locate the AppMessage tag handler parent, using TagSupport.findAncestorWithClass(), and call a public method on the parent to pass it the parameter value. Assuming the method is called addParameter(), the Param tag handler looks something like this: public class ParamTag extends TagSupport { private String value; public void setValue(String value) { this.value = value; } public int doEndTag() throws JspException { AppMessageTag parent = (AppMessageTag) findAncestorWithClass(this, AppMessageTag.class); if (parent == null) { throw new JspException("The param action is not " + "enclosed by a supported action type"); } parent.addParameter(value); return EVAL_PAGE; } } In the AppMessage tag handler, this method adds the value to some sort of collection (e.g. a List), and is used in the doEndTag() method to parameterize the message. You must also make sure you remove all values between invokations, since the tag handler may be reused for other occurances of the action element. A good place to do this is in the doStartTag() method. I hope this helps, Hans -- Hans Bergsten [EMAIL PROTECTED] Gefion Software http://www.gefionsoftware.com JavaServer Pages http://TheJSPBook.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com