I have never seen Properties-Keys with '@' as a part of it. I also can't find any documentation of this anywhere. If I google it I can't find anything. Does someone here have any clue of what this might be? I guess it is some kind of scope, like depending on the action, because both Examples above are being referenced to in the JSP with only the part after the '@', e.g.
Struts 2 uses standard Java classes for localization. The base class for that functionality is java.util.Properties. I don't see anything in that documentation or the Java Tutorial that specifically addresses what you are seeing. I built a simple test class to print out some properties:
Here is my property file:
And when I run it, here is the output:
So it looks like using the full property key with an '@' sign works, as does just using the portion after the '@' sign. Note that using the portion before the '@' does not work.
I don't know what purpose this function would have if it is intentional.
if one and the same JSP is being referenced from different Struts-Actions (via tiles etc.) and there's a struts text tag like
I can write two different properties for this field, depending on the Action where it is used. If it is used in "administration", I create a property like
where it is a different text as if being referenced from "customer", where the property
is being used. Strange thing is, I can't find any documentation about that. If it is Legacy code from a colleague before me, I don't know how he managed to achieve a feature like that. I'd love to know where I can find code which could do that. I tried the text.ftl file, but couldn't find anything here... Any suggestions of how to find something via IDE search (using Intellij)?
Do you have these properties defined in separate files? I wonder if this is a way to specify which resource bundle to use.
The search order for resources starts with the action class. OGNL uses the '@' character to statically reference classes or fields, so that may be the documentation you are looking for. Of course, it is probably unnecessary, since the search order hits the action properties file first anyway.
Joe Ess wrote:Do you have these properties defined in separate files?
they are all in one properties-File called "Messages.properties" (and because it is a localized Webapp in different languages, many more properties-files for each language, e.g. "Messages_en_GB.properties"). I guess that's not a default struts 2 Ressource Bundle, so I looked for a custom.resources definition, which I know is possible, strange thing is, I couldn't find any. My guess is that there is some kind of magic legacy code behind all this, nothing struts 2-out-of-the-box... :-(