NOTE: This is outdated information that applies only to Tapestry 4. |
Overwrite tapestry's ComponentMessagesSourceImpl like this ...
the new ComponentMessagesSource implementation
public class Core4ComponentMessagesSourceImpl extends ComponentMessagesSourceImpl { /** * Returns an instance of {@link java.util.Properties}containing the properly localized messages for the * component, in the {@link java.util.Locale}identified by the component's containing page. */ protected synchronized Properties getLocalizedProperties(IComponent component) { Properties tapestryProperties = super.getLocalizedProperties(component); INamespace iNamespace = component.getNamespace(); while (iNamespace != null && !iNamespace.isApplicationNamespace()) iNamespace = iNamespace.getParentNamespace(); if (iNamespace != null) { iNamespace.getSpecificationLocation().getPath(); String globalMessagefile = iNamespace.getSpecification().getProperty("global.message.file"); if (globalMessagefile == null) throw new ApplicationRuntimeException("application property 'global.message.file' not set!"); globalMessagefile = component.getPage().getRequestCycle().getInfrastructure(). getContextRoot().getRelativeResource(globalMessagefile).getResourceURL().getFile(); try { FileInputStream fileInputStream = new FileInputStream(globalMessagefile); tapestryProperties.load(fileInputStream); fileInputStream.close(); } catch (IOException e) { throw new ApplicationRuntimeException(e); } } return tapestryProperties; } }
your application hivemind.xml
<implementation service-id="tapestry.ComponentMessagesSource"> <invoke-factory> <construct class="de.hsofttec.core4.service.impl.Core4ComponentMessagesSourceImpl"> <event-listener service-id="tapestry.ResetEventHub"/> <set-object property="componentPropertySource" value="infrastructure:componentPropertySource"/> </construct> </invoke-factory> </implementation>
put this in your application properties
<meta key="global.message.file" value="WEB-INF/conf/global.messages.properties"/>