You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lukas Bradley <lu...@somnia.com> on 2003/10/30 17:25:41 UTC

Multiple -- How to access? Struts 1.1

Hi all,

I feel rather odd asking about this, because it seems it should be a VERY
simple task.

I've been using a single message-resource within my struts-config.xml file.
It's been working beautifully defined as:
<message-resources parameter="MyTerms" null="false"/>

When I have a file "MyTerms.properties" in my /WEB-INF/classes directory.  I
access my properties as such:

<bean:message key="label.forum.subject" />

And everything the world is perfect.

Except that my properties file has filled up with hundreds of terms, and it
is getting impossible to manage.  To make this easier, I decided to define
multiple message-resources in my struts-config.

<message-resources parameter="MyTerms" null="false"/>

<message-resources parameter="msg.resource.errors" key="msg.errors"
null="false" />

<message-resources parameter="msg.forum" key="msg.forum" null="false" />

It is my understanding that the initial "MyTerms" file will be stored under
the default resources property, and the other two will be stored as
"msg.errors" and "msg.forum" respectively.

However, when I try to access them, I get nothing.

<bean:message key="label.forum" messages="msg.forum"/>

<bean:message key="label.forum" name="msg.forum"/>

<bean:message key="label.forum" bundle="msg.forum"/>

None of the tags above work.  I even tried

<bean:message property="label.forum" bundle="msg.forum"/>

But that gives a NullPointerException.

So I'm stumped.  In the logs, the property file is being loaded during
startup, and my default property file still returns messages.

Any help?

Lukas










---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Multiple -- How to access? Struts 1.1

Posted by Lukas Bradley <lu...@somnia.com>.
It appears as if the properties file can not contain the "." character.
This makes sense, because properties are considered to be Class files at run
time.  The dot-notation probably gets a little confusing.

This works:

<message-resources parameter="MyForum" key="msg.forum" null="false"/>

<bean:message key="label.forum" bundle="msg.forum"/>

Where the properties file is named MyForum.properites.

Lukas


"Lukas Bradley" <lu...@somnia.com> wrote in message
news:bnre2k$e43$1@localhost.localdomain...
> Hi all,
>
> I feel rather odd asking about this, because it seems it should be a VERY
> simple task.
>
> I've been using a single message-resource within my struts-config.xml
file.
> It's been working beautifully defined as:
> <message-resources parameter="MyTerms" null="false"/>
>
> When I have a file "MyTerms.properties" in my /WEB-INF/classes directory.
I
> access my properties as such:
>
> <bean:message key="label.forum.subject" />
>
> And everything the world is perfect.
>
> Except that my properties file has filled up with hundreds of terms, and
it
> is getting impossible to manage.  To make this easier, I decided to define
> multiple message-resources in my struts-config.
>
> <message-resources parameter="MyTerms" null="false"/>
>
> <message-resources parameter="msg.resource.errors" key="msg.errors"
> null="false" />
>
> <message-resources parameter="msg.forum" key="msg.forum" null="false" />
>
> It is my understanding that the initial "MyTerms" file will be stored
under
> the default resources property, and the other two will be stored as
> "msg.errors" and "msg.forum" respectively.
>
> However, when I try to access them, I get nothing.
>
> <bean:message key="label.forum" messages="msg.forum"/>
>
> <bean:message key="label.forum" name="msg.forum"/>
>
> <bean:message key="label.forum" bundle="msg.forum"/>
>
> None of the tags above work.  I even tried
>
> <bean:message property="label.forum" bundle="msg.forum"/>
>
> But that gives a NullPointerException.
>
> So I'm stumped.  In the logs, the property file is being loaded during
> startup, and my default property file still returns messages.
>
> Any help?
>
> Lukas




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org