-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
i have separated a module with zul's and composers in a jar. Works perfect. Where i'm now struggeling is how to load the I18N labels from this jar.
In the base application i have a custom LabelLocator who can collect all property file in the war /WEB-INF/labels folder.
I want not copy the module labels in the base app only it's the only way for it.
Any information and code are appreciate.
thanks Stephan
Hi Kai, in my case i will first collect all found file names, make a unique list without the locale and than call the registering method. This works for WEB-INF/labels but at time not for the module jar.
So my problem at first is how i get the property files in the module.
thx Stephan
Hi Stephen, might I have not understood your problem correctly. In my application I have several jar files. Each jar file brings their own label files. These are located in the jar file in the directory web/labels/'specific for jar'/. Each jar file is taking her own LabelLocator, which the own files can locate with ~./labels/'specific for jar' and registered with Labels.register (). After the first access to an entry in the label files you can identify all known strings with Labels.getSegmentedLabels(). The names of the respective files you can not determine (or I do not know how), the only exception, all objects of type LabelLocator registered themselves in a component additionally provided of you.
Kai
Kai, how do you start the location process in the module jar? I have tried it with a lang-addon.xml and modified resource names in 'mesg' folder. But without luck.
For each module a webAppInit in the web.xml ?
Is it a problem to show the code? At time i have really not get it to run. Can be that one reason is my windows machine. But i get only the resource from my development project in the 'target' forlder. So i see the files but cannot register it in LabelLocator
thx Stephan
my Skype is: TerryTornado
OK. It runs now in jars but not in my way. The ONLY way i get the loading of the labels are 'do nothing' and use the standard folder and the standard file names as used in the ZK LabelLoaderImpl.java. Otherwise i get not the right URL. Seems a classloader problem. I have alltimes get the URL from my eclipse projects '/target/classes/ path. Beside, i'm testing this with Eclipse and Tomcat 7.0.47
The loading mechanism is started following: (The whole codes will be offered soon with 'ZKBoost')
/**
* ModuleInitializer. Implemented the javax.servlet.ServletContainerInitializer
* interface so it should be called if the web application is started and this
* class is inside a jar in the WEB-INF/lib folder.<br>
* ----------------------------------------------------------------------------<br>
*
* @see javax.servlet.ServletContainerInitializer
* @Blog http://piotrnowicki.com/2011/03/using-servlets-3-0-
* servletcontainerinitializer/<br>
* @author Stephan Gerth
*/
public class ModuleInitializer implements javax.servlet.ServletContainerInitializer
{
@Override
public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException {
System.out.println("ZKBOOST: [START MODULE]: magelaan");
collectLabels(ctx);
}
thanks Stephan
Hi Stephen, since you're already ahead of me a piece. For me, the application knows which jar files are involved. For their LabelLocator types generates objects and registers them. A quasi-plug-in mechanism with a module initializer I have not yet. The localization of the label files in the jar within LabelLocator::locate () I perform with WebApp::getResource(). For a path such as ~./labels/... I get the URI with the reference in the jar file.
Kai
Asked: 2014-05-21 16:10:50 +0800
Seen: 32 times
Last updated: May 23 '14