File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Kick off localization in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Kick off localization in JSF" Watch "Kick off localization in JSF" New topic

Kick off localization in JSF

Russell Bateman
Ranch Hand

Joined: Feb 26, 2008
Posts: 69
In my .jsp, I've got:

...and running the file I see

Caused by:
org.apache.jasper.el.JspPropertyNotFoundException - /login.jsp(22,8) '#{msg.catalog.title}' Property 'title' not found on type java.lang.String

Of course, I've got a file on the (Eclipse) path src/com/mydomain/catalog/ (as well as one in French). I also tried (and using "messages_en" in place of "messages" in loadBundle), but to no avail. In those message files I've got:

In faces-config.xml I have:

Would someone explain the conceptual link between having messages, having an <application> tag in faces-config.xml and doing a loadBundle in the JSP? I'd like to figure this out, but so far, neither Google nor experimenting has helped. Or a link to someplace that explains.

Profuse thanks in advance,

Russ Bateman
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

"#{msg.catalog.title}" is EL for "msg.getCatalog().getTitle()". Not what you want.

Without doing anything as intelligent as actually checking, I believe that the proper syntax is: "#{msg['catalog.title']}, since I'm pretty sure that "msg" is a map, and that's how you lookup map keys in EL.

An IDE is no substitute for an Intelligent Developer.
Russell Bateman
Ranch Hand

Joined: Feb 26, 2008
Posts: 69
Thank you very much. I had seen that construct here and there while Googling, but not understood what it was specifically for. One article in particular misled me into the syntax I chose. It seemed reasonable and I moved on puzzled as to why it wasn't working. I'm not certain how long it would have been before it dawned on me, so I thank you very much for this.

I agree. Here's the link:
subject: Kick off localization in JSF
It's not a secret anymore!