Embedded ZK Application"
Line 8: | Line 8: | ||
=Prerequisite= | =Prerequisite= | ||
==Settings in the ZK application== | ==Settings in the ZK application== | ||
− | + | We use library property to enable the embedded feature. | |
− | We use library property to | + | For example: (In zk.xml) |
− | |||
− | |||
<source lang="xml"> | <source lang="xml"> | ||
<library-property> | <library-property> | ||
− | <name>org.zkoss.web.servlet.http.embedded. | + | <name>org.zkoss.web.servlet.http.embedded.enabled</name> |
− | <value> | + | <value>true</value> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</library-property> | </library-property> | ||
</source> | </source> |
Revision as of 04:14, 29 November 2019
Employment/Purpose
Instead of using iframe, there is a new way to use ZK in a non-ZK web container. For example, we could use NodeJs, Python, etc. as the web application, and embed another ZK application in the web pages.
- Available for ZK:
[ since 9.0.0 ]
Prerequisite
Settings in the ZK application
We use library property to enable the embedded feature. For example: (In zk.xml)
<library-property>
<name>org.zkoss.web.servlet.http.embedded.enabled</name>
<value>true</value>
</library-property>
Settings in the other application
When using Embedded ZK, there might be some ZK resource URLs start with "/", which means that it would try to load the resource from our non-ZK application. See more about the update-uri.
To deal with this problem, we should handle the requests whose target is ZK application by redirecting those requests to the ZK URL. We could use Nginx or some apache solutions.
Example
After doing all the settings in the ZK application and the non-ZK application, now we could embed ZK pages in our web application. <syntax lang="html" high="11"> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body>
Loading...
<script defer src="http://localhost:8080/zktest/test.zul?zk.domId=embeddedZK"></script> </body> </html> </syntax>
In line 11, we use <script> to embed test.zul, and the "zk.domId" means that the embedded ZK page would be rendered in the corresponding DOM Element (DOM id).
Version History
Version | Date | Content |
---|---|---|
9.0.0 |