File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts ActionMessage not displaying multiple dynamic values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts ActionMessage not displaying multiple dynamic values" Watch "Struts ActionMessage not displaying multiple dynamic values" New topic
Author

Struts ActionMessage not displaying multiple dynamic values

Shaily Shah
Greenhorn

Joined: Mar 15, 2010
Posts: 3
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}?

Thanks in advance.



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

"ab first cd later", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
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
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://aspose.com/file-tools
 
subject: Struts ActionMessage not displaying multiple dynamic values
 
Similar Threads
Help need in query
c:if tag
Extract values from a string
Manfred please help
About JButton