Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts ActionMessage not displaying multiple dynamic values

 
Shaily Shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65658
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ab first cd later", please check your private messages for an important administrative matter.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried debugging it..? Just add struts' source to your IDE and set a breakpoint on ActionMessage's constructor...
 
Shaily Shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!