Struts ActionMessage not displaying multiple dynamic values
Shaily Shah
Greenhorn
Joined: Mar 15, 2010
Posts: 3
posted
0
Hi,
We are using Struts ActionMessages to display error messages in UI. For one of the error message I need to pass more than 5 dynamic values e.g.
msgKey = test string {0} {1} {2} {3} {4} {5}
In my code I am passing Object array with 6 values
new ActionMessage("msgKey", new Object[] {"Val1","Val2","Val3","Val4","Val5","Val6"});
Now in UI, I can see values "test string Val1 Val2 Val3 Val4 Val5 {5}"
I read in some forums that if you have single quotes in the string and if it is not escaped that might create such issue but in my string i don't have any single quote or double quote but still i don't see 6th value.
Any idea why it is not showing actual value and showing {5}?
Have you tried debugging it..? Just add struts' source to your IDE and set a breakpoint on ActionMessage's constructor...
Shaily Shah
Greenhorn
Joined: Mar 15, 2010
Posts: 3
posted
0
Hi Lorand,
I have not tried debugging it yet.
We are using Struts 1.x and this is what i found in apache struts API documentation. Looks like only 4 place holders are supported by struts ActionMessages.
public class ActionMessages
extends java.lang.Object
implements java.io.Serializable
A class that encapsulates messages. Messages can be either global or they are specific to a particular bean property.
Each individual message is described by an ActionMessage object, which contains a message key (to be looked up in an appropriate message resources database), and up to four placeholder arguments used for parametric substitution in the resulting message.
Thanks
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Struts ActionMessage not displaying multiple dynamic values