You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ylva Degerfeldt <yl...@gmail.com> on 2008/08/11 18:18:58 UTC

[Struts 2] NetBeans can't find my ResourceBundle properties file (localization issue)

Hi,

I'm trying to use the localization method of having property files
that define all the visible text using keys and values (e.g.
"nameAndCv.title = Namn och cv"), but the problem is that NetBeans
(5.5.1) can't seem to find my properties file (I only have one).

I've read in "Struts 2 in Action" that all you should have to do to
make this work is to define some property files and put them in a
place where Struts 2 can find them (Then ResourceBundles should be
automatically created). There should be many options for this place
but I've already tried two and it didn't work.

One try: Have all the message strings in the same package as the
action class, and call the file "package.properties". This is supposed
to work but didn't. (It shouldn't matter that I have several action
classes in the same package, right?)

Another try: I kept the file from above but tried to explicitly define
where Struts 2 should find it, both in struts.properties, like this:

struts.custom.i18n.resources = Web.StrutsActions.package

and in struts.xml, like this:

<constant name="struts.custom.i18n.resources" value =
"Web.StrutsActions.package"/>

The Web package is directly underneath \src\java, but I shouldn't have
to specify that, or should I?


The problem is (just to be clear) that when I try to execute, for
instance this tag:
<s:text name = "nameAndCv.title"/>
..the properties file can't be found so what is printed is literally
"nameAndCv.title"

Does anyone have a solution to this problem? That would be great!

Thanks in advance!

/Ylva

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


Re: [Struts 2] NetBeans can't find my ResourceBundle properties file (localization issue)

Posted by Ylva Degerfeldt <yl...@gmail.com>.
Thanks a lot for answering again, Dave!
I felt that my latest questions hardly deserved an answer since they
were too basic. For that reason I have been reading some stuff myself
to try to find answers.. (See below.)

> If you're calling a JSP page directly (almost never a good idea) it won't go through the action request process, so you won't have anything on the value stack. Most S2 tags depends on something being on the value stack--like <s:text...>.
Yes, I suspected something like that.

> You can configure an action without a class and S2 will use (normally) ActionSupport, the default execute() method returns "success":
>
> <action name="foo">
>  <result>/WEB-INF/jsps/foo.jsp</result>
> </action>

Yes, I just read about that, but I didn't know that Struts
automatically uses ActionSupport in this case. Good to know. Then I
understand.

>> And how do I tell NetBeans that it should start by running an action?
>
> I'm not sure how to answer that; all NetBeans will do is start the application server, and you make requests to the app.
Ok, I'll try to find that out by myself.

/Ylva

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

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


Re: [Struts 2] NetBeans can't find my ResourceBundle properties file (localization issue)

Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 8/11/08, Ylva Degerfeldt <yl...@gmail.com> wrote:
> Well the action that should be executed after a submit from
> the first page (called "NameAndCv.jsp") extends ActionSupport.
> 
> But maybe this problem is due to another thing I'm
> insecure about...
> 
> I run my application just by the Run command of NetBeans,
> having set the welcome-file tag to "NameAndCv.jsp" in
> web.xml. Your question reminded me that I'm unsure about 
> how to actually start the application (yes, I'm a complete 
> newbie about Struts 2). Do I have to start by calling an 
> action (and not by calling a JSP), and how do I do
> that? Is there some standard, already defined action that I
> can call (since this action only has to return "success"
> and nothing else)? 

If you're calling a JSP page directly (almost never a good idea) it won't go through the action request process, so you won't have anything on the value stack. Most S2 tags depends on something being on the value stack--like <s:text...>.

You can configure an action without a class and S2 will use (normally) ActionSupport, the default execute() method returns "success":

<action name="foo">
  <result>/WEB-INF/jsps/foo.jsp</result>
</action>

> And how do I tell NetBeans that it should start by running an action?

I'm not sure how to answer that; all NetBeans will do is start the application server, and you make requests to the app.

Dave


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


Re: [Struts 2] NetBeans can't find my ResourceBundle properties file (localization issue)

Posted by Ylva Degerfeldt <yl...@gmail.com>.
Thanks Dave, for answering!

Well the action that should be executed after a submit from the first
page (called "NameAndCv.jsp") extends ActionSupport.

But maybe this problem is due to another thing I'm insecure about...

I run my application just by the Run command of NetBeans, having set
the welcome-file tag to "NameAndCv.jsp" in web.xml. Your question
reminded me that I'm unsure about how to actually start the
application (yes, I'm a complete newbie about Struts 2). Do I have to
start by calling an action (and not by calling a JSP), and how do I do
that? Is there some standard, already defined action that I can call
(since this action only has to return "success" and nothing else)? And
how do I tell NetBeans that it should start by running an action?

I will search for the answers myself too..

/Ylva

On Mon, Aug 11, 2008 at 6:26 PM, Dave Newton <ne...@yahoo.com> wrote:
> Does the action being executed extend ActionSupport?
>
> Dave
>
>
> --- On Mon, 8/11/08, Ylva Degerfeldt <yl...@gmail.com> wrote:
>
>> From: Ylva Degerfeldt <yl...@gmail.com>
>> Subject: [Struts 2] NetBeans can't find my ResourceBundle properties file (localization issue)
>> To: "Struts Users Mailing List" <us...@struts.apache.org>
>> Date: Monday, August 11, 2008, 12:18 PM
>> Hi,
>>
>> I'm trying to use the localization method of having
>> property files
>> that define all the visible text using keys and values
>> (e.g.
>> "nameAndCv.title = Namn och cv"), but the problem
>> is that NetBeans
>> (5.5.1) can't seem to find my properties file (I only
>> have one).
>>
>> I've read in "Struts 2 in Action" that all
>> you should have to do to
>> make this work is to define some property files and put
>> them in a
>> place where Struts 2 can find them (Then ResourceBundles
>> should be
>> automatically created). There should be many options for
>> this place
>> but I've already tried two and it didn't work.
>>
>> One try: Have all the message strings in the same package
>> as the
>> action class, and call the file
>> "package.properties". This is supposed
>> to work but didn't. (It shouldn't matter that I
>> have several action
>> classes in the same package, right?)
>>
>> Another try: I kept the file from above but tried to
>> explicitly define
>> where Struts 2 should find it, both in struts.properties,
>> like this:
>>
>> struts.custom.i18n.resources = Web.StrutsActions.package
>>
>> and in struts.xml, like this:
>>
>> <constant name="struts.custom.i18n.resources"
>> value =
>> "Web.StrutsActions.package"/>
>>
>> The Web package is directly underneath \src\java,
>> but I shouldn't have
>> to specify that, or should I?
>>
>>
>> The problem is (just to be clear) that when I try to
>> execute, for
>> instance this tag:
>> <s:text name = "nameAndCv.title"/>
>> ..the properties file can't be found so what is printed
>> is literally
>> "nameAndCv.title"
>>
>> Does anyone have a solution to this problem? That would be
>> great!
>>
>> Thanks in advance!
>>
>> /Ylva
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail:
>> user-help@struts.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: [Struts 2] NetBeans can't find my ResourceBundle properties file (localization issue)

Posted by Dave Newton <ne...@yahoo.com>.
Does the action being executed extend ActionSupport?

Dave


--- On Mon, 8/11/08, Ylva Degerfeldt <yl...@gmail.com> wrote:

> From: Ylva Degerfeldt <yl...@gmail.com>
> Subject: [Struts 2] NetBeans can't find my ResourceBundle properties file (localization issue)
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Date: Monday, August 11, 2008, 12:18 PM
> Hi,
> 
> I'm trying to use the localization method of having
> property files
> that define all the visible text using keys and values
> (e.g.
> "nameAndCv.title = Namn och cv"), but the problem
> is that NetBeans
> (5.5.1) can't seem to find my properties file (I only
> have one).
> 
> I've read in "Struts 2 in Action" that all
> you should have to do to
> make this work is to define some property files and put
> them in a
> place where Struts 2 can find them (Then ResourceBundles
> should be
> automatically created). There should be many options for
> this place
> but I've already tried two and it didn't work.
> 
> One try: Have all the message strings in the same package
> as the
> action class, and call the file
> "package.properties". This is supposed
> to work but didn't. (It shouldn't matter that I
> have several action
> classes in the same package, right?)
> 
> Another try: I kept the file from above but tried to
> explicitly define
> where Struts 2 should find it, both in struts.properties,
> like this:
> 
> struts.custom.i18n.resources = Web.StrutsActions.package
> 
> and in struts.xml, like this:
> 
> <constant name="struts.custom.i18n.resources"
> value =
> "Web.StrutsActions.package"/>
> 
> The Web package is directly underneath \src\java,
> but I shouldn't have
> to specify that, or should I?
> 
> 
> The problem is (just to be clear) that when I try to
> execute, for
> instance this tag:
> <s:text name = "nameAndCv.title"/>
> ..the properties file can't be found so what is printed
> is literally
> "nameAndCv.title"
> 
> Does anyone have a solution to this problem? That would be
> great!
> 
> Thanks in advance!
> 
> /Ylva
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org

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