Inter-Web-Application Communication"
Maya001122 (talk | contribs) m (Created page with '{{ZKDevelopersGuidePageHeader}} __TOC__ An EAR file could have multiple WAR files. Each of them is a Web application. There are no standard way to communicate between two Web a…') |
m (correct highlight (via JWB)) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersGuidePageHeader}} | {{ZKDevelopersGuidePageHeader}} | ||
+ | |||
+ | {{Old Version | ||
+ | |url=https://www.zkoss.org/wiki/ZK_Developer%27s_Reference/UI_Patterns/Communication/Inter-Application_Communication | ||
+ | |}} | ||
+ | |||
__TOC__ | __TOC__ | ||
Line 5: | Line 10: | ||
An EAR file could have multiple WAR files. Each of them is a Web application. There are no standard way to communicate between two Web applications. | An EAR file could have multiple WAR files. Each of them is a Web application. There are no standard way to communicate between two Web applications. | ||
− | However, ZK supports a way to reference the resource from another Web applications. For example, assume you want to include a resource, say < | + | However, ZK supports a way to reference the resource from another Web applications. For example, assume you want to include a resource, say <code>/foreign.zul</code>, from another Web application, say <code>app2</code>. Then, you could do as follows. |
<include src="~app2/foreign.zul"/> | <include src="~app2/foreign.zul"/> | ||
Line 16: | Line 21: | ||
</source> | </source> | ||
− | Note: Whether you can access a resource located in another Web application depends on the configuration of the Web server. For example, you have to specify < | + | Note: Whether you can access a resource located in another Web application depends on the configuration of the Web server. For example, you have to specify <code>crossContext="true"</code> in conf/context.xml, if you are using Tomcat. |
=== Web Resources from Classpath === | === Web Resources from Classpath === | ||
Line 23: | Line 28: | ||
<image src="~./my/jar.gif"/> | <image src="~./my/jar.gif"/> | ||
− | Then, it tries to locate the resource, < | + | Then, it tries to locate the resource, <code>/my/jar.gif</code>, at the /web directory by searching resources from the classpath. |
There are three ways to place file in classpath. | There are three ways to place file in classpath. |
Latest revision as of 10:40, 19 January 2022
This documentation is for an older version of ZK. For the latest one, please click here.
This documentation is for an older version of ZK. For the latest one, please click here.
An EAR file could have multiple WAR files. Each of them is a Web application. There are no standard way to communicate between two Web applications.
However, ZK supports a way to reference the resource from another Web applications. For example, assume you want to include a resource, say /foreign.zul
, from another Web application, say app2
. Then, you could do as follows.
<include src="~app2/foreign.zul"/>
Similarly, you could reference resources from another Web application.
<style src="~app2/foo.css"/> <!-- assume foo.css is in the context called app2 -->
<image src="~/foo.png"/> <!-- assume foo.png is in the root context -->
Note: Whether you can access a resource located in another Web application depends on the configuration of the Web server. For example, you have to specify crossContext="true"
in conf/context.xml, if you are using Tomcat.
Web Resources from Classpath
With ZK, you could reference a resource that is locatable by the classpath. The advantage is that you could embed Web resources in a JAR file, which simplifies the deployment.
<image src="~./my/jar.gif"/>
Then, it tries to locate the resource, /my/jar.gif
, at the /web directory by searching resources from the classpath.
There are three ways to place file in classpath.
Under java src folder
Create web
folder under src
folder. ~.
will search src/web. For example src/web/my/jar.gif
can be found by <image src="~./my/jar.gif"/>
.
Under WebContent folder
Create classes/web
under WebContent/WEB-INF
folder. For example WebContent/WEB-INF/classes/web/my/jar.gif
can be found by <image src="~./my/jar.gif"/>
.
Jar the file
You may jar the resource and place it under WebContent/WEB-INF/lib
folder. For <image src="~./my/jar.gif"/>
, the file should be under web/my/jar.gif
inside the jar file.