wood burning stoves 2.0*
The moose likes Struts and the fly likes aboout struts-config and properties file in struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "aboout struts-config and properties file in struts application " Watch "aboout struts-config and properties file in struts application " New topic
Author

aboout struts-config and properties file in struts application

Sekhar Chand
Ranch Hand

Joined: Apr 05, 2006
Posts: 73
hai friends,

I have some small doubts regarding struts frame work.
I want to know how many struts-config.xml files that we can create in the same project.if we can create then how can we switch actions
How many properties files we can write.If we can write more than one properties file and If one message has to return from one properties file and we have more than one properties file. Then how to get that message value.

I know some partial answer for first question. I don't know whether it is correct or not.
Ans --> We can write struts-config.xml file for each module if we have more than one module in our application.
Sekhar Chand
Ranch Hand

Joined: Apr 05, 2006
Posts: 73
anybody is there to clear my doubt
Yogendra Joshi
Ranch Hand

Joined: Apr 04, 2006
Posts: 213
Hello Reddy ,

First of all , When you post something on the forum , You need to keep patience for the other ranchers to help you out with your query. This is a helpful forum not an answer home where you put your query and it would automatically generate an answer.

Now , Lets come to the question in place ,

"I want to know how many struts-config.xml files that we can create in the same project.if we can create then how can we switch actions"

Well , As and when the application size grows and each member of the team has to work on its own module , You can define seperate struts-config file specific to your module. This can be achieved like this :

In the deployment descriptor(web.xml) add an <init-param> element with its child elements i.e param-name and param-value something like this :

<init-param>
<param-name>config/module1</param-name>
<param-value>/WEB-INF/struts-module1-config.xml</param-value>
</init-param>

The new module is defined by adding an initialization parameter config/module1. In fact any init-param prefixed with "config/" is interpreted as configuration for a separate module.

Now when you want to switch between actions from struts-config to new created struts-config file , You would need to use SwitchAction details of which you can Google. Its much simpler to access it.

Now the second question :

How many properties files we can write.If we can write more than one properties file and If one message has to return from one properties file and we have more than one properties file. Then how to get that message value.

This too can be any number of Message Resources file. For this in the struts-config file , You already have a default application resource bundle something similar to this :

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

Now when you want to add a new one , Just add one more element like this :

<message-resources key="yogendra" parameter="MessageResources_en" null="false"/>

Note the use of the key attribute in the above message-resources element.

So, Configure as much as you want and give different key attributes for every different element and then when you want to use it on the jsp , you need to do something similar to like this :

<bean:message key="UserRegistration.Title" bundle="yogendra"/>

Thats it Buddy.

Hope this helped you. If you have any further query , Just ping us.
Regards ,

Yogendra N Joshi.


Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
 
wood burning stoves
 
subject: aboout struts-config and properties file in struts application
 
Similar Threads
struts1
Issue with multiple struts-config...
Struts-config.xml
Hello from the author: an introduction to the book
Can we use two struts-config.xml in one struts application