Bug 18521

Summary: MessageTag body misuse
Product: Taglibs Reporter: Patrick Samson <p_samson>
Component: I18N TaglibAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: MessageTag patch

Description Patrick Samson 2003-03-31 14:42:23 UTC
In this situation:
 <i18n:message key="exist">text</i18n:message>
 <i18n:message key="doesn't exist"/>
then the second tag shows the content of the first one.
This is because in the first step, a body is assigned
but not used (so not .clear() ), and in the second step
no body is assigned, but needed and one already exists.
Comment 1 Patrick Samson 2004-04-07 09:06:00 UTC
To fix this bug,
- Add this method in MessageTag.java
     *  If key is not found, use the body content as a default value.
    public int doAfterBody() throws JspException
        // if the value is null, use the body content
        if ( _value == null ) {
          _value = bodyContent.getString();
        // cleanup
    	return SKIP_BODY;
- Remove this part from doEndTag() in MessageTag.java
            // if the value is null, use the body content
            if ( _value == null ) {
                _value = bodyContent.getString();
Comment 2 Martin Cooper 2004-04-07 18:48:04 UTC
Please supply patches created using 'cvs diff -u'. That makes it much simpler 
for us to apply them. Thanks.
Comment 3 Patrick Samson 2004-06-02 15:02:01 UTC
Created attachment 11729 [details]
MessageTag patch
Comment 4 Felipe Leme 2004-06-04 04:36:51 UTC
Applied changes to CVS, thanks for the patch.
Comment 5 Felipe Leme 2004-06-04 04:46:13 UTC
*** Bug 18523 has been marked as a duplicate of this bug. ***