• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to put carriage return in MessageResource.properties?

 
Jonilie Echavez
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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?

 
Dawn Charangat
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try:

error.duplicate=Duplicate record found.<br>
 
Prakash Mani - Attur
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
oh yes very good idea...thanks David..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic