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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re-using value in resource bundle

Status
Not open for further replies.
Dec 8, 2003
17,047
GB
Hi,

I've defined a key/value pair at the top of my messages.properties resource bundle:

Code:
login.url=http://www.somedomain.com/someurl.html

and I want to re-use that further down in the same file, within some HTML code, e.g.:

Code:
somekey.html=<p>Click <a href="[!]url re-use wanted here[/!]">here</a> to log in</p>

I was advised that using the original key surrounded by @ symbols might work, but I'm finding that not to be the case. I've tried all of the following combinations, but am having no luck:

Code:
somekey.html=<p>Click <a href="@login.url@">here</a> to log in</p>
somekey.html=<p>Click <a href="\@login.url\@">here</a> to log in</p>
somekey.html=<p>Click <a href="@@login.url@@">here</a> to log in</p>

Is there an easy way to do this? I'd rather not duplicate the URL. If it makes any difference, these valeus are output using the <spring:message> tag.

I'm not a Java developer, so apologies if I've got any of the terminology wrong!

Thanks,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
AFAIK, @s should work.

What value is the property getting?

Cheers,
Dian
 
I'm getting the exact text back that's in the value - so "@login.url@", "\@login.url\@", or "@@login.url@@" for the above three examples.

Perhaps there's a configuration option I need to enable to allow this to work?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Now that I thought it for a bit ... how are you reading the properties file?

If I remember OK, default java mechanismo doesn't allow that kind of substitution. I'm trying to remember which one I used to do that.

Cheers,
Dian
 
We're using Spring 2.0 framework, and then <spring:message> tag with a key, e.g.:

Code:
<spring:message code="some.key.here" />

to display the messages on the page. I assumed this was a simple extension of the Java ResourceBundle stuff (which I don't fully understand).

At present, I've simply duplicated the URL about 5 times, but I view that as really inefficient, and prone to errors when being edited, so would definately like to be able to re-use existing values.

Thanks,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
JFig might do what you want.
Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top