You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/03/07 02:22:34 UTC

DO NOT REPLY [Bug 17750] New: - bean:message could be more power with little effort

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17750>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17750

bean:message could be more power with little effort

           Summary: bean:message could be more power with little effort
           Product: Struts
           Version: 1.1 RC1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: sandymac@ufl.edu


A lot of power in the bean:message taglib is lost because the setters/getters
for the arg0 though arg4 take java.lang.String arguments instead of
java.lang.Object. This is because it makes it impossible to pass a subclass of
java.lang.Number as one of the arguments.

For example if in my app's Message.properties I have the property:

how.many.messages={0,choice,0#No messages|1#One message|1<Lots of messages}

and I use the bean:message taglib in the following way:

<bean:message key="how.many.messages" arg0="<%= "12" %>"/>

The java.text.ChoiceFormat fails in the method
java.text.NumberFormat.format(Object,StringBuffer,FieldPosition) with a
"java.lang.IllegalArgumentException: Cannot format given Object as a Number"
because "12" is a string and not a subclass of Number.

If I use the bean:message taglib in the following way:

<bean:message key="how.many.messages" arg0="<%= new Integer(12) %>"/>

The JSP fails to compile because there is no way to cast an Integer to a String.

I really wish it wasn't so but I understand it's probably too late in the game
to get this change made by Struts 1.1. It would be nice that if in the
documentation a note is added mentioning that the bean:message taglib only
allows only very simplistic parametric replacement so people like myself don't
assume we have access to the full power of java.text.MessageFormat and waste a
few hours trying to figure out why things are breaking.

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org