0

How to load labels from jar

asked 2014-05-21 16:10:50 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2014-05-21 16:11:36 +0800

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

delete flag offensive retag edit

6 Answers

Sort by ยป oldest newest most voted
0

answered 2014-05-22 06:37:18 +0800

khcyt gravatar image khcyt
216 1

Hi Stephan, i have the label files (i.e. i3-labels.properties) under web/labels in the jar-file and can then locate them via ~./lables/i3-labels.properties.

Kai

link publish delete flag offensive edit
0

answered 2014-05-22 10:05:10 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

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

link publish delete flag offensive edit
0

answered 2014-05-22 13:07:15 +0800

khcyt gravatar image khcyt
216 1

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

link publish delete flag offensive edit
0

answered 2014-05-22 14:04:15 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2014-05-22 14:07:09 +0800

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

link publish delete flag offensive edit
0

answered 2014-05-22 17:54:51 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2014-05-22 18:10:16 +0800

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

link publish delete flag offensive edit
0

answered 2014-05-23 07:03:45 +0800

khcyt gravatar image khcyt
216 1

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

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-05-21 16:10:50 +0800

Seen: 32 times

Last updated: May 23 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More