-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I want to load all zk language properties files from different application jars dynamically. How can I do that in zk..?
You can do that in your dependent jars.
/**
* ModuleInitializer. Implemented the javax.servlet.ServletContainerInitializer
* interface so it can be called if the web application is started and this
* class is inside a jar that is placed in the WEB-INF/lib folder of the main
* web application.<br>
* The ServletContainerInitializer is a feature from servlet 3.0 specifications.
* ----------------------------------------------------------------------------<br>
*
* @see javax.servlet.ServletContainerInitializer
* @Blog http://piotrnowicki.com/2011/03/using-servlets-3-0-
* servletcontainerinitializer/<br>
* <br>
*
* @author Stephan Gerth
*/
public class DummyModuleInitializer implements javax.servlet.ServletContainerInitializer {
private static final Logger log = LoggerFactory.getLogger(DummyModuleInitializer.class);
/**
* Default constructor.
*/
public DummyModuleInitializer() {
super();
}
@Override
public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException {
// log.debug("ZKBOOST: [STARTING UI MODULE]: empty dummy module");
System.out.println("ZKBOOST: [STARTING UI MODULE]: empty dummy module");
registerLabels(ctx);
}
/**
* Registers the labels. The I18N file name are set in the
* OXModuleLabelLocator().
*
* @see com.myfirm.dummy.init.DummyModuleLabelLocator
* @param ctx
* The ServletContext.
*/
public void registerLabels(ServletContext ctx) {
Labels.register(new DummyModuleLabelLocator(ctx));
}
}
/**
* Module LabelLocator for URL.<br>
* --------------------------------------------------------<br>
* The files should be zk default named and in zk default folder.<br>
* FileNames: <b>zk-label</b>.properties or <b>zk-label</b>_de_DE.properties,
* ...<br>
* Folder: src/main/resources/metainfo/ <br>
*
* @author Stephan Gerth
*/
public class DummyModuleLabelLocator implements org.zkoss.util.resource.LabelLocator, Serializable {
/**
* Serial Version UID.
*/
private static final long serialVersionUID = 1L;
/**
* The servlet context.
*/
private ServletContext ctx;
/**
* Constructor.
*
* @param _ctx
* Servlet context.
*/
public DummyModuleLabelLocator(ServletContext _ctx) {
this.ctx = _ctx;
}
@Override
public URL locate(Locale _locale) throws Exception {
/**
* The '/' before the resource name is needed for running in Tomcat 8.
*/
if (_locale != null) {
return ctx.getResource("/zk-label" + "_" + _locale + ".properties");
} else {
return ctx.getResource("/zk-label" + ".properties");
}
}
}
best Stephan
Asked: 2017-06-13 14:11:14 +0800
Seen: 17 times
Last updated: Jun 13 '17
ZK 7.0.3 doAfterCompose is not called for GenericForwardComposer
Power of ZK Calender With Charts 2 and Other Components
ZK7 atlantic theme: vlayout/hlayout spacing
Structuring zul-code without includes?
css zk 7.0.3 with ie9 not work
Change listbox MVVM template with Java or how to let user change column order