简体   繁体   中英

Load ZUL from Jar

anyone know how to load a Zul from a Jar? I have a library project wich contains Zul. currently i use createComponents(String uri, Component parent, Map arg) but i don't know or can't reference a uri in a jar.


I use now:

public static Component createComponentsFromJar(final String path, final Component parent, final Map<?,?> arg) throws IOException {
    final InputStream resourceAsStream = ComponentHelper.class.getClassLoader().getResourceAsStream(path);
    final PageDefinition pageDefinition = Executions.getCurrent().getPageDefinitionDirectly(new InputStreamReader(resourceAsStream), "zul");
    resourceAsStream.close();
    return Executions.createComponents(pageDefinition, parent, arg);
}

does any know some problems with this method of creating new pages? Some binding problems or someting?

Executions.createComponents will work with ZK Specific URI (refer to Inter-Application Communication ) where "~./ " in ZK Specific URI will get the file under "classpath/web/ ", assume your zul page under "src/web/zul/pages" as below:

src下的zul页面

And you export the src folder as a jar, then you can create component with the zul file in jar as below:

Executions.createComponents("~./zul/pages/zulInJar.zul", parent, null);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM