• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to put carriage return in MessageResource.properties?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Struts MessageResource.properties file has the following key, where i wanted to insert a carriage return after the message.

error.duplicate=Duplicate record found.\n

But in the output of the jsp file, the message is displayed with the '\n' instead of the carriage return expected.

Output:
Duplicate record found.\n

How do i properly insert this escape character?

 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try:

error.duplicate=Duplicate record found.<br>
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Jonilie Echavez

i think you want to display the error message in the list format. if your aim is so then use the following.

errors.header=<UL><font color="red" face="Arial" size="1">
errors.prefix=<LI>
errors.suffix=</LI>
errors.footer=</font></UL>

put the above in the top of the properties file.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Personally, I think it's a bad idea to keep formatting information like this in a resource file.
 
Prakash Mani - Attur
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi david
then how to show the errors in the list format. i cant use the <li> tag every where i have to show the error message in the jsp file. please tell me the alternate idea you have.
 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I'm not sure what you are doing when you output this error message, so this may not be relevent but I reckon that you could avoid this issue with the use of CSS and properly formatting your HTML. If for example you're trying to get the errors to appear next to an input then take a look at this tutorial: http://articles.sitepoint.com/article/fancy-form-design-css/7

If you are wanting it to appear in a list form (I'm assuming here that you take in a list of error messages) do it in the JSP and certainly not from your messages file:


I have to say though the most simple way is just to style it using some html/css.

Sean
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prakash Attur wrote:hi david
then how to show the errors in the list format. i cant use the <li> tag every where i have to show the error message in the jsp file. please tell me the alternate idea you have.


Why not? Or why not create a custom tag to do it?

My point is that embedding things like <br> tags in the resource file is a pain, and explicitly ties the error message to the page layout. The idea behind things like resource files is to separate concerns.
 
Prakash Mani - Attur
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh yes very good idea...thanks David..
reply
    Bookmark Topic Watch Topic
  • New Topic