Re: How to pull messages from multiple Bundles?
I'm doing the same thing on my current webapp. You can define as many ressources as you want in your struts-config.xml. Let's define two ressources in your struts-config.xml kile this (the bundle attribute allows to identify ressources) message-resources parameter=package.ressources.default / message-resources key=buttons parameter=package.ressources.buttons / message-resources key=errors parameter=package.ressources.errors / and one in your struts-config-module.xml message-resources parameter=package.module.ressources.default / Then, in your module page : a) doing bean:message key=my.key / will search the property in 'package/module/ressources/default.properties' b) doing bean:message bundle=errors key=invalid / will get the message from 'package/ressources/errors/properties' Conclusion : you can split all your general messages into several message-ressources in your struts-config.xml, and each bundle will be accessible from any module. HTH, Thomas At 18:14 17/09/2003, you wrote: Hi, I want to seperate my message bundle into multiple bundles instead of just using one big block. (For eg) GenericMessages error.invalid={0} contians invalid data. Module1Messages invalid.amount={0} must be atleast 5. I do my validation by myself (not using the Validator) So the application component that identifies these errors creates action errors like: ActionError e= new ActionError(error.invalid, arg1); and then add the ActionErrors to the request scope and they are displayed via html:errors tag Now if all the keys comes from the same bundle it is not a problem. If i want to display both the messages error.invalid invalid.amount how would i do that? Appreciate any help Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
I asked virtually the same question yesterday and got a similar answer. Unfortunately this seems to imply that the jsp has to know about how you arrange your message files which is disappointing. - Original Message - From: Thomas Cornet [EMAIL PROTECTED] Newsgroups: Struts Sent: Wednesday, September 17, 2003 8:04 AM Subject: Re: How to pull messages from multiple Bundles? I'm doing the same thing on my current webapp. You can define as many ressources as you want in your struts-config.xml. Let's define two ressources in your struts-config.xml kile this (the bundle attribute allows to identify ressources) message-resources parameter=package.ressources.default / message-resources key=buttons parameter=package.ressources.buttons / message-resources key=errors parameter=package.ressources.errors / and one in your struts-config-module.xml message-resources parameter=package.module.ressources.default / Then, in your module page : a) doing bean:message key=my.key / will search the property in 'package/module/ressources/default.properties' b) doing bean:message bundle=errors key=invalid / will get the message from 'package/ressources/errors/properties' Conclusion : you can split all your general messages into several message-ressources in your struts-config.xml, and each bundle will be accessible from any module. HTH, Thomas At 18:14 17/09/2003, you wrote: Hi, I want to seperate my message bundle into multiple bundles instead of just using one big block. (For eg) GenericMessages error.invalid={0} contians invalid data. Module1Messages invalid.amount={0} must be atleast 5. I do my validation by myself (not using the Validator) So the application component that identifies these errors creates action errors like: ActionError e= new ActionError(error.invalid, arg1); and then add the ActionErrors to the request scope and they are displayed via html:errors tag Now if all the keys comes from the same bundle it is not a problem. If i want to display both the messages error.invalid invalid.amount how would i do that? Appreciate any help Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
Thomas, You didn't get the question. I understand that multiple bundles can be used in bean:write or other tags that understand i18n. Question is: Application identifies two errors- errors.invalid (found in bundle1) invalid.amount (found in bundle2) When i create these errors and add it to the request scope how do i tell it which bundle do these keys exist in? If i say html:errors to display my errors how would it know that one of the error keys is from bundle1 while the other is from bundle2? Hope that clarifies the question Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
Oh, excuse me. Looking at the DTDs, it seems that html:errors tag has a 'bundle' parameter, so something like : html:errors bundle=errors property=your_property This should search errors message in the right message ressource, if they are all in the same. Thomas PS : ActionError class just stores the key, which is only processed by html:errors during page generation At 23:54 17/09/2003, you wrote: Thomas, You didn't get the question. I understand that multiple bundles can be used in bean:write or other tags that understand i18n. Question is: Application identifies two errors- errors.invalid (found in bundle1) invalid.amount (found in bundle2) When i create these errors and add it to the request scope how do i tell it which bundle do these keys exist in? If i say html:errors to display my errors how would it know that one of the error keys is from bundle1 while the other is from bundle2? Hope that clarifies the question Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
I don't believe you can. html:errors or html:messages can only accept a single message bundle. daniel manglu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thomas, You didn't get the question. I understand that multiple bundles can be used in bean:write or other tags that understand i18n. Question is: Application identifies two errors- errors.invalid (found in bundle1) invalid.amount (found in bundle2) When i create these errors and add it to the request scope how do i tell it which bundle do these keys exist in? If i say html:errors to display my errors how would it know that one of the error keys is from bundle1 while the other is from bundle2? Hope that clarifies the question Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
Thomas, Thanks. This variant that you are referring to is the one that places the errors to the side of the property that causes trouble. Is that right? I still want a single view at the top which outlines all the errors yet the message can come from multiple bundles. Is this achievable? Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
At 00:37 18/09/2003, you wrote: Thomas, Thanks. This variant that you are referring to is the one that places the errors to the side of the property that causes trouble. Is that right? Yep I still want a single view at the top which outlines all the errors yet the message can come from multiple bundles. Is this achievable? I don't think so, because 'bundle' parameter allows only one value. I'm afraid you'll have to write your own tag subclassing ErrorsTag to resolve your specific problem. Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
They are the same tablib, i.e. html:errors or html:messages and you can only specify one optional bundle with each of these tags. If you really want to implement this, you can subclass or modify ActionMessage to allow you to specify a message bundle, and subclass ErrorsTag to use the specified bundle with each message. It should actually be pretty easy, probably only 10-20 lines of code. daniel manglu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thomas, Thanks. This variant that you are referring to is the one that places the errors to the side of the property that causes trouble. Is that right? I still want a single view at the top which outlines all the errors yet the message can come from multiple bundles. Is this achievable? Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to pull messages from multiple Bundles?
fmt:setBundle fmt:bundle - Original Message - From: Carlos Sánchez [EMAIL PROTECTED] To: 'Struts Users Mailing List' [EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 6:53 AM Subject: RE: How to pull messages from multiple Bundles? Another question which I've already asked but nobody answered Is there any way to configure multiple bundles to use with JSTL fmt:msg tag? -Mensaje original- De: Thomas Cornet [mailto:[EMAIL PROTECTED] Enviado el: miércoles, 17 de septiembre de 2003 11:44 Para: Struts Users Mailing List Asunto: Re: How to pull messages from multiple Bundles? At 00:37 18/09/2003, you wrote: Thomas, Thanks. This variant that you are referring to is the one that places the errors to the side of the property that causes trouble. Is that right? Yep I still want a single view at the top which outlines all the errors yet the message can come from multiple bundles. Is this achievable? I don't think so, because 'bundle' parameter allows only one value. I'm afraid you'll have to write your own tag subclassing ErrorsTag to resolve your specific problem. Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to pull messages from multiple Bundles?
Oh, sorry, forget my last post and here's an aswer to your problem (which was also mine) Watch this from thread Multiple message resources with JSTL -Mensaje original- De: Kris Schneider [mailto:[EMAIL PROTECTED] Enviado el: viernes, 12 de septiembre de 2003 16:35 Para: Struts Users Mailing List Asunto: Re: Multiple message resources with JSTL Here's something that appears to be a step in the right direction. First, use a single context init param for javax.servlet.jsp.jstl.fmt.localizationContext. The param-value content should match the parameter attribute of the message-resources element in your default Struts config file. For example, your default Struts config file would include: message-resources parameter=com.obs.webapp.messages.Messages/ Then, add something like the following to a module Struts config file: message-resources parameter=com.obs.webapp.messages.MessagesModule1/ Finally, extend SwitchAction like so: import javax.servlet.jsp.jstl.core.Config; ... public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionForward forward = super.execute(mapping, form, request, response); ModuleConfig moduleConfig = RequestUtils.getModuleConfig(request, getServlet().getServletContext()); MessageResourcesConfig messageConfig = moduleConfig.findMessageResourcesConfig(Globals.MESSAGES_KEY); if (messageConfig != null) { Config.set(request, Config.FMT_LOCALIZATION_CONTEXT, messageConfig.getParameter()); } return forward; } So, as long as you use the new switch action to move between modules, it should pick up the messages associated with the new module and make them available to JSTL. I haven't looked into how to integrate with module switching via a forward with contextRelative=true, but there might be something possible there as well... Quoting Carlos Sanchez [EMAIL PROTECTED]: I'm using JSTL + Struts configured for modules I'm using JSTL fmt tag for messages, instead of Struts tags, configured in web.xml context-param param-namejavax.servlet.jsp.jstl.fmt.localizationContext/pa ram-name param-valuecom.obs.webapp.messages.Messages/param-value /context-param I'd like to add more message resources, one for each module. Adding more context-param's doesn't work, it uses the last one. Can I configure it in web.xml, have I to use fmt:setBundle in the jsps, ...? -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to pull messages from multiple Bundles?
Hi, I want to seperate my message bundle into multiple bundles instead of just using one big block. (For eg) GenericMessages error.invalid={0} contians invalid data. Module1Messages invalid.amount={0} must be atleast 5. I do my validation by myself (not using the Validator) So the application component that identifies these errors creates action errors like: ActionError e= new ActionError(error.invalid, arg1); and then add the ActionErrors to the request scope and they are displayed via html:errors tag Now if all the keys comes from the same bundle it is not a problem. If i want to display both the messages error.invalid invalid.amount how would i do that? Appreciate any help Manglu - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]