You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@gmail.com on 2010/12/01 22:15:51 UTC
Internationalization with REST/Convention plug-ins
I had a guy ask me why his internationalized properties were not accessible
in his Struts app that was using both the REST and Convention plug-ins. My
first action was to read the docs which did not suggest anything out of the
ordinary, so I through a core app together using this configuration and sure
enough the properties were not found!
He is using
<constant name="struts.convention.action.suffix" value="Controller"/>
So I figured an Action called FooController would find
FooController.properties in the same folder as the FooController.class,
which as it turns out did *not* work. I set a breakpoint at the top of
LocalizedTextUtil and the localist contains only the following two files
[org/apache/struts2/struts-messages,
com/opensymphony/xwork2/xwork-messages]. Shouldn't this collection include
my FooController.properties on a request http://.../foo? Including a
message key from struts-messages works fine, however a key from
FooController.properties returns the key itself as it is not being located.
public static String findDefaultText(String aTextName, Locale locale) {
List<String> localList = DEFAULT_RESOURCE_BUNDLES;
for (String bundleName : localList) {
ResourceBundle bundle = findResourceBundle(bundleName, locale);
if (bundle != null) {
reloadBundles();
try {
return bundle.getString(aTextName);
} catch (MissingResourceException e) {
// ignore and try others
}
}
}
return null;
}
Re: Internationalization with REST/Convention plug-ins
Posted by stanlick <st...@gmail.com>.
de-rust? That's awesome. I personally am afraid to see what might be
lurking under all my rust.
There is a struts.convention.package.locators set to the top-level folder in
the class hierarchy. One thing that I found interesting though, I added the
struts2-config-browser-plugin hoping to get a better look at the runtime and
discovered the url .../foo/config-browser/index.action throws a 404. When I
removed the index.action I get the following stack trace. You know, all
these plug-ins are great, but debugging this or that combination being used
is a PITA!
java.lang.IllegalArgumentException: The index() is not defined in action
class com.opensymphony.xwork2.ActionSupport
org.apache.struts2.rest.RestActionInvocation.invokeAction(RestActionInvocation.java:105)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:130)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
Dave Newton-6 wrote:
>
> I got caught out by thinking the packages were created in a different
> package than I assumed they were, but I don't recall if it was my fault or
> if there was a configuration parameter I had forgotten to set or what.
>
> But just in case it helps, I'll throw it out there.
>
> Man, I've forgotten a lot of stuff--I really need to de-rust myself :(
>
> Dave
>
> On Wed, Dec 1, 2010 at 4:15 PM, <st...@gmail.com> wrote:
>
>> I had a guy ask me why his internationalized properties were not
>> accessible
>> in his Struts app that was using both the REST and Convention plug-ins.
>> My
>> first action was to read the docs which did not suggest anything out of
>> the
>> ordinary, so I through a core app together using this configuration and
>> sure
>> enough the properties were not found!
>>
>> He is using
>>
>> <constant name="struts.convention.action.suffix" value="Controller"/>
>>
>> So I figured an Action called FooController would find
>> FooController.properties in the same folder as the FooController.class,
>> which as it turns out did *not* work. I set a breakpoint at the top of
>> LocalizedTextUtil and the localist contains only the following two files
>> [org/apache/struts2/struts-messages,
>> com/opensymphony/xwork2/xwork-messages]. Shouldn't this collection
>> include
>> my FooController.properties on a request http://.../foo? Including a
>> message key from struts-messages works fine, however a key from
>> FooController.properties returns the key itself as it is not being
>> located.
>>
>> public static String findDefaultText(String aTextName, Locale locale)
>> {
>> List<String> localList = DEFAULT_RESOURCE_BUNDLES;
>>
>> for (String bundleName : localList) {
>> ResourceBundle bundle = findResourceBundle(bundleName,
>> locale);
>> if (bundle != null) {
>> reloadBundles();
>> try {
>> return bundle.getString(aTextName);
>> } catch (MissingResourceException e) {
>> // ignore and try others
>> }
>> }
>> }
>>
>> return null;
>> }
>>
>
>
--
View this message in context: http://old.nabble.com/Internationalization-with-REST-Convention-plug-ins-tp30353436p30353656.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Internationalization with REST/Convention plug-ins
Posted by Dave Newton <da...@gmail.com>.
I got caught out by thinking the packages were created in a different
package than I assumed they were, but I don't recall if it was my fault or
if there was a configuration parameter I had forgotten to set or what.
But just in case it helps, I'll throw it out there.
Man, I've forgotten a lot of stuff--I really need to de-rust myself :(
Dave
On Wed, Dec 1, 2010 at 4:15 PM, <st...@gmail.com> wrote:
> I had a guy ask me why his internationalized properties were not accessible
> in his Struts app that was using both the REST and Convention plug-ins. My
> first action was to read the docs which did not suggest anything out of the
> ordinary, so I through a core app together using this configuration and
> sure
> enough the properties were not found!
>
> He is using
>
> <constant name="struts.convention.action.suffix" value="Controller"/>
>
> So I figured an Action called FooController would find
> FooController.properties in the same folder as the FooController.class,
> which as it turns out did *not* work. I set a breakpoint at the top of
> LocalizedTextUtil and the localist contains only the following two files
> [org/apache/struts2/struts-messages,
> com/opensymphony/xwork2/xwork-messages]. Shouldn't this collection include
> my FooController.properties on a request http://.../foo? Including a
> message key from struts-messages works fine, however a key from
> FooController.properties returns the key itself as it is not being located.
>
> public static String findDefaultText(String aTextName, Locale locale) {
> List<String> localList = DEFAULT_RESOURCE_BUNDLES;
>
> for (String bundleName : localList) {
> ResourceBundle bundle = findResourceBundle(bundleName, locale);
> if (bundle != null) {
> reloadBundles();
> try {
> return bundle.getString(aTextName);
> } catch (MissingResourceException e) {
> // ignore and try others
> }
> }
> }
>
> return null;
> }
>