Embedded ZK Application"

From Documentation
Line 32: Line 32:
 
==Settings in the other application==
 
==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.
 
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 [[ZK_Configuration_Reference/web.xml/ZK_Loader|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.
 
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.
 
We could use Nginx or some apache solutions.
See more about the [[ZK_Configuration_Reference/web.xml/ZK_Loader|update-uri]].
 
  
 
=Example=
 
=Example=

Revision as of 09:43, 20 November 2019


Embedded ZK Application


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:
  • http://www.zkoss.org/product/zkhttp://www.zkoss.org/whyzk/zkeeVersion ee.png
[ since 9.0.0 ]

Prerequisite

Settings in the ZK application

For security reasons, we need to set the origin server white list, which means only the predefined web application could access our ZK application. We use library property to set the allowed origin (In zk.xml).

For example:

<library-property>
	<name>org.zkoss.web.servlet.http.embedded.AllowOrigin</name>
	<value>http://localhost:9000</value>
</library-property>

Another setting is that we should define the target URL. Then all the HTTP requests in ZK would be redirected to the correct URL.

For example:

<library-property>
	<name>org.zkoss.web.servlet.http.embedded.TargetURL</name>
	<value>http://localhost:8080/zktest</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 HTML file. <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>

Version History

Last Update : 2019/11/20


Version Date Content
9.0.0



Last Update : 2019/11/20

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.