DO NOT REPLY [Bug 4836] New: - org/apache/struts/util/LocalStrings message format wrong

2001-11-13 Thread bugzilla

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
.
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=4836

org/apache/struts/util/LocalStrings message format wrong

   Summary: org/apache/struts/util/LocalStrings message format wrong
   Product: Struts
   Version: Nightly Build
  Platform: PC
OS/Version: Linux
Status: NEW
  Severity: Normal
  Priority: Other
 Component: Custom Tags
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]


org/apache/struts/util/LocalStrings has a messed up formating entry for 
parameters.multi. When specifying a name attribute for  that 
doesn't resolve to a Map you'll get an IllegalArgumentException in 
java.text.MessageFormat instead of the actual error message. Attached diff 
against the cvs version should make it clear. 

This being my first bug report I hope that it's useful to someone.

diff -u -1 -r1.4 LocalStrings.properties
--- LocalStrings.properties 2001/10/16 17:15:25 1.4
+++ LocalStrings.properties 2001/11/13 13:14:15
@@ -11,3 +11,3 @@
 message.bundle=Cannot find message resources under key {0}
-parameters.multi=Cannot cast to Map for name={0} property={1e} scope={2}
+parameters.multi=Cannot cast to Map for name={0} property={1} scope={2}
 parameters.single=Cannot cast to String for name={0} property={1} scope={2}

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




html:link using bean parameters (was: DO NOT REPLY [Bug 4836] New: - org/apache/struts/util/LocalStrings message format wrong)

2001-11-13 Thread Daniel Temme

Hi,

> parameters.multi. When specifying a name attribute for 
> that doesn't resolve to a Map you'll get an IllegalArgumentException in
> java.text.MessageFormat instead of the actual error message. 

while I'm at it... The reason that I actually stumbled across this was that I 
was trying to append the properties of a bean to the link parameters. 

Now I'm curious whether it would be possible to extend the functionality of 
RequestUtils to also handle this case.

I've attached a diff that should illustrate this and so far seems to work for 
me. (Although I'm not sure about the exception handling.)

Have a nice day
Daniel Temme

Index: RequestUtils.java
===
RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
retrieving revision 1.23
diff -u -r1.23 RequestUtils.java
--- RequestUtils.java	2001/10/16 15:48:28	1.23
+++ RequestUtils.java	2001/11/13 16:37:44
@@ -191,9 +191,21 @@
 // Locate the Map containing our multi-value parameters map
 Map map = null;
 try {
-if (name != null)
-map = (Map) lookup(pageContext, name,
-   property, scope);
+if (name != null) {
+		Object lookup = lookup(pageContext, name,
+   property, scope);
+		if (lookup instanceof Map)
+		map = (Map) lookup;
+		else 
+		try {
+			map = BeanUtils.describe(lookup);
+		} catch (Exception e) {
+			saveException(pageContext, e);
+			throw new JspException
+			(messages.getMessage("parameters.multi", name,
+		 property, scope));
+		}
+	}
 } catch (ClassCastException e) {
 saveException(pageContext, e);
 throw new JspException


--
To unsubscribe, e-mail:   
For additional commands, e-mail: