• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

aboout struts-config and properties file in struts application

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody is there to clear my doubt
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic