4

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?

Kani
  • 810
  • 1
  • 19
  • 38
  • Why You are mixing web project with Pure java coding i never saw this type of coding – Subodh Joshi Feb 11 '13 at 12:24
  • I made a dynamically wizard, you can add pages to the wizard like: pages.add(new WizardPageConfig(SOMEID, "/pages/personWizard/pageStart.zul")); this wizard logic is in our framework and the file upload page for the wizard is a default zul, wich should be in the framework too. – Kani Feb 11 '13 at 13:22
  • is this fiddle kind of thing? – Subodh Joshi Feb 11 '13 at 13:24
  • i cant fiddle that cause i think fzkfiddle does not support usage of jars :D – Kani Feb 11 '13 at 16:02
  • @subodh this is a very common way of creating components in the ZK framework, you can see an example in [ImageLabel.java here](http://www.zkoss.org/zkdemo/composite/composite_component). Kani, this is a very good question. I hope you get an answer, I'll be putting some thought into it. – Sean Connolly Feb 12 '13 at 13:41
  • @Sean can you please let me know where in composite Component we need to add ZUL file inside Jar file? – Subodh Joshi Feb 12 '13 at 16:49

1 Answers1

6

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:

zul page under src

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);
benbai123
  • 1,423
  • 1
  • 11
  • 11