Serving zul files from a directory outside web application

asked 2019-03-30 04:05:33 +0800

jgomer2001 gravatar image jgomer2001
80 2

updated 2019-04-01 21:26:09 +0800

I am wondering if it is possible to place zul files outside the web application folder or war file.

I would like to have my ViewModels and supporting classes as normally in WEB-INF/classes but certain zul files in a separate external location so I could, for instance, add some zul files on the fly.

In JSF this can be achieved by using javax.faces.view.facelets.ResourceResolver or javax.faces.application.ResourceHandler...

Any insight is highly appreciated. I was navigating the docs, especially ZK config reference manual 8.5.1 but didn't seem to find a fit. I'm wondering about org.zkoss.zk.ui.util.URIInterceptor

Ideally I would like to solve the problem declarively.

This is for production use. I have an application where plugins can be added at runtime. This works pretty well. In plugins, developers can bundle zul files...

I use jetty so app's .war ends up extracted to a random temp directory. By using servletContext.getRealPath("/") I know this physical path, so I simply extract the files there. That way, zul files are served with no effort

The problem arises in a clustered environment (same app running at different nodes), because the temp path is not the same across all nodes, so I need to use a predefined location to place zul files.

Thanks for reading!

delete flag offensive retag edit


is this for development or production use? An answer or recommendation would likely vary based on the intended purpose.

cor3000 ( 2019-04-01 12:51:18 +0800 )edit

Hi cors3000, I added more text to the problem description. This text field for replying is limited. Thank you!

jgomer2001 ( 2019-04-01 21:27:29 +0800 )edit

Thanks for contributing @hawk , it is close to what I need, however jars are added at runtime (using a plugin framework - pf4j) so unfortunately, these are not present in the classpath.

jgomer2001 ( 2019-04-03 21:25:21 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-04-04 21:21:37 +0800

jgomer2001 gravatar image jgomer2001
80 2

updated 2019-04-11 12:31:06 +0800

cor3000 gravatar image cor3000
4466 2 7
ZK Team

After some more digging I found this (I cannot paste links):

wiki > Developer's Reference > Customization > UI Factory

So I will follow a strategy similar to that of loading zul from database, but reading instead from a static external filesystem location

I hope that should do it

link publish delete flag offensive edit


thanks for the update (I guess I missed that feature since it's rarely used/asked for) ... I added some Karma so you can post links next time

cor3000 ( 2019-04-11 12:30:43 +0800 )edit

answered 2019-04-03 09:49:30 +0800

hawk gravatar image hawk
2320 1 5
http://hawkphoenix.blogsp... ZK Team

I think Classpath Web Resource Path can fulfill your requirement.

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

1 follower



Asked: 2019-03-30 04:05:33 +0800

Seen: 21 times

Last updated: Apr 11

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