Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MessageResources.getMessage method

Status
Not open for further replies.

bluepixie

Programmer
Jul 31, 2003
34
US
I am having several problems getting my ArrayList data to show in a message box. I am ready to just scrap the message box and create a new page but I thought I would ask for help first.

This is the method pasted form the javadoc I am calling:

--------------
public java.lang.String getMessage(java.lang.String key,
java.lang.Object[] args)

Returns a text message after parametric replacement of the specified parameter placeholders.

Parameters:
key - The message key to look up
args - An array of replacement parameters for placeholders
--------------

My results display like this:

"text goes here (0)"

So, can I pass an ArrayList in or will I need to convert it?

And do I need to know the amount of elements in the array? The wording was vague in the javadoc and I couldn't tell. How would the resource file be set up if the # of elements in the array is ever changing?

Thanks
 
Hi,

Covert the ArrayList to Object[] using toArray() of arrayList and try.

Ex:
message = "text goes here {0} and here as well {1}"
Object[] = {one,two}
Result = "text goes here one and here as well two"

the resouces file will be based on array index.

Cheers
Venu

 
Ok, thanks, I am working on that.

I think that I may have another problem. I need to format the message with html. Anything that I try adding to the resource file, strings or objects will not work. I have tried <br> and /n. Is this not possible with MessageResources?

Thanks!
 
Hi,

It is possible to include html tags as In one of my case I creat hyperlink from the properties file

Ex:

banner.page.link=<a href="{1}" title="Go to page {0}">{0}</a>

Cheers
Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top