This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes Properties from util classes used by Action Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Properties from util classes used by Action" Watch "Properties from util classes used by Action" New topic
Author

Properties from util classes used by Action

Vijay Ganapathy
Greenhorn

Joined: May 23, 2012
Posts: 13
Hi everyone,

I just want to know if there's a way to access the properties from a utility class used by an Action class. To access the properties from an Action class we extend the ActionSupport and use the getText("property.key.name") method.
So, my question is -should every other class extend the ActionSupport to access properties, even though its not an Action class? or is there any other way?

Thanks
Vijay
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
A Struts Properties file should be used for Struts-based classes only. Application classes that are not Struts-based should not be using the Struts Properties file. They should use their own Properties file instead.
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Avoid cross posting Access properties from util classes used by Action


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Vijay Ganapathy
Greenhorn

Joined: May 23, 2012
Posts: 13
Jimmy Clark wrote:A Struts Properties file should be used for Struts-based classes only. Application classes that are not Struts-based should not be using the Struts Properties file. They should use their own Properties file instead.


Thanks for your reply. So, should I be using a different framework for loading the application properties?
Like Apache commons or Resourcebundle.
I guess, my question is ActionSupport sounds more specific to an Action, is there a generic component within struts that can load not only struts properties, but also application properties.
I'm pretty comfortable and happy that I didnt have to do addl. coding to load props because of ActionSupport but just a little inconvenient to have every class either extend ActionSupport or implement another mechanism to load properties. Does it make sense?

Vijay Ganapathy
Greenhorn

Joined: May 23, 2012
Posts: 13
Mohana Rao Sv wrote:Avoid cross posting Access properties from util classes used by Action


Mohana: I understand how ActionSupport works. Please stop giving obvious answers without understanding the question.
AFAIK, coderanch and stackoverflow are different web sites.
Different web sites are visited by different people.
Different people have different levels of knowledge and different opinions.
Please explain to me whats the problem in cross posting.

Thanks
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Loading data from a Properties file is relatively easy. I suggest that you first create a class that will load data from a Properties file. Once this class is created and working properly, then you can start to explore other potential options. Good luck!
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

http://www.coderanch.com/how-to/java/BeForthrightWhenCrossPostingToOtherSites
Vijay Ganapathy
Greenhorn

Joined: May 23, 2012
Posts: 13
Mohana Rao Sv wrote:http://www.coderanch.com/how-to/java/BeForthrightWhenCrossPostingToOtherSites


Thanks. I'll keep that in mind
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Properties from util classes used by Action
 
Similar Threads
displaying data - reuse
Struts 2 and validation Framework
Struts 2: forward from jsp to another
Can I access the Application Context from a Struts 2 Action?
getWebApplicationContext() w/ Struts