ZK Loader"
Maya001122 (talk | contribs) |
|||
(20 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{ZKConfigurationReferencePageHeader}} | ||
+ | |||
+ | =DHtmlLayoutServlet= | ||
+ | |||
Location: WEB-INF/web.xml | Location: WEB-INF/web.xml | ||
− | + | '''[Required] Class:''' <javadoc>org.zkoss.zk.ui.http.DHtmlLayoutServlet</javadoc> | |
− | [Required] Class: <javadoc>org.zkoss.zk.ui.http.DHtmlLayoutServlet</javadoc> | + | |
− | |||
− | + | ZK Loader is a servlet used to load ZUML pages when the Web server receives URL requests sent by the users. | |
− | Notice that you must specify < | + | Notice that you must specify <code>load-on-startup</code> since many other servlets depend on the ZK loader. |
<source lang="xml" > | <source lang="xml" > | ||
Line 13: | Line 16: | ||
</source> | </source> | ||
− | + | Here is [[ZK_Configuration_Reference/web.xml/Sample_of_web.xml|a complete sample]]. | |
− | + | = The Initial Parameters = | |
{| border="1" | {| border="1" | ||
Line 28: | Line 31: | ||
It specifies the URI which the ZK AU engine is mapped to. | It specifies the URI which the ZK AU engine is mapped to. | ||
− | For example, if the ZK AU engine is mapped to < | + | For example, if the ZK AU engine is mapped to <code>/zkau/*</code>, by the use of <code>servlet-mapping</code>, then specify <code>/zkau</code> for this parameter. |
− | Note: if the servlet container is used with other Web server, like Apache, you have to map this update URI to the servlet container (in additions to < | + | Note: if the servlet container is used with other Web server, like Apache, you have to map this update URI to the servlet container (in additions to <code>zul</code> and <code>zhtml</code> files). |
+ | |||
+ | |- | ||
+ | | resource-uri | ||
+ | | | ||
+ | {{versionSince| 9.5.0}} | ||
+ | [Optional] | ||
+ | |||
+ | It specifies the URI which the [[ZK_Configuration_Reference/web.xml/ZK_Resource_Engine | ZK Resource engine]] is mapped to. | ||
+ | |||
+ | For example, if the ZK Resource engine is mapped to <code>/zkres/*</code>, by the use of <code>servlet-mapping</code>, then specify <code>/zkres</code> for this parameter. | ||
+ | |||
+ | Note: if the servlet container is used with other Web server, like Apache, you have to map this resource URI to the servlet container (in additions to <code>zul</code> and <code>zhtml</code> files). | ||
|- | |- | ||
| compress | | compress | ||
− | | [Optional][Default:< | + | | [Optional][Default:<code>true</code>] |
− | It specifies whether to compress the output if the browser supports the compression (< | + | It specifies whether to compress the output if the browser supports the compression (<code>Accept-Encoding</code>) and this Servlet is not included by other Servlets. |
|- | |- | ||
Line 45: | Line 60: | ||
− | It specifies the default log level for < | + | It specifies the default log level for <code>org.zkoss</code>. If not specified, the system default (usually <code>INFO</code>) is used. |
− | Possible values: < | + | Possible values: <code>OFF</code>, <code>ERROR</code>, <code>WARNING</code>, <code>INFO</code>, <code>DEBUG</code> and <code>FINER</code>. Please refer to [[ZK Developer's Reference/Supporting Utilities/Logger|ZK Developer's Reference]] for details. |
|} | |} | ||
+ | |||
+ | = Map URL to ZUML pages= | ||
+ | |||
+ | It is suggested to map this servlet to the <code>zul</code> and <code>zhtml</code> extensions as shown below to process ZUML pages. It is OK if you want to prefer to use <code>xul</code> and <code>html</code> as the extension; just map them to ZK Loader too. | ||
+ | |||
+ | <source lang="xml" > | ||
+ | <servlet> | ||
+ | <description>ZK loader for evaluating ZUML pages</description> | ||
+ | <servlet-name>zkLoader</servlet-name> | ||
+ | <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> | ||
+ | <init-param> | ||
+ | <param-name>update-uri</param-name> | ||
+ | <param-value>/zkau</param-value> | ||
+ | </init-param> | ||
+ | <load-on-startup>1</load-on-startup><!-- MUST --> | ||
+ | </servlet> | ||
+ | <servlet-mapping> | ||
+ | <servlet-name>zkLoader</servlet-name> | ||
+ | <url-pattern>*.zul</url-pattern> | ||
+ | </servlet-mapping> | ||
+ | <servlet-mapping> | ||
+ | <servlet-name>zkLoader</servlet-name> | ||
+ | <url-pattern>*.zhtml</url-pattern> | ||
+ | </servlet-mapping> | ||
+ | </source> | ||
+ | |||
+ | Here is [[ZK_Configuration_Reference/web.xml/Sample_of_web.xml|a complete sample]]. | ||
+ | |||
+ | =Map URL to Richlets= | ||
+ | |||
+ | Assume you have a [[ZK Developer's Reference/UI Composing/Richlet|richlet]] named <code>foo.FooRichlet</code>. Then, you could configure it as follows. | ||
+ | |||
+ | First, declare the richlet: | ||
+ | |||
+ | <source lang="xml" > | ||
+ | <richlet> | ||
+ | <richlet-name>Foo</richlet-name> | ||
+ | <richlet-class>foo.FooRichlet</richlet-class> | ||
+ | </richlet> | ||
+ | </source> | ||
+ | |||
+ | Second, map the richlet to any number of URL you want: | ||
+ | |||
+ | <source lang="xml" > | ||
+ | <richlet-mapping> | ||
+ | <richlet-name>Foo</richlet-name> | ||
+ | <url-pattern>/foo</url-pattern> | ||
+ | </richlet-mapping> | ||
+ | <richlet-mapping> | ||
+ | <richlet-name>Fest</richlet-name> | ||
+ | <url-pattern>/some/more/*</url-pattern> | ||
+ | </richlet-mapping> | ||
+ | </source> | ||
+ | |||
+ | Notice that, by default, richlets are disabled. To enable them, add the following declaration to <code>web.xml</code>. Once enabled, you can add as many as richlets as you want without modifying <code>web.xml</code> any more. Of course, <code>url-pattern</code> could be any pattern you prefer. | ||
+ | |||
+ | <source lang="xml" > | ||
+ | <servlet-mapping> | ||
+ | <servlet-name>zkLoader</servlet-name> | ||
+ | <url-pattern>/zk/*</url-pattern><!-- any pattern you prefer --> | ||
+ | </servlet-mapping> | ||
+ | </source> | ||
+ | |||
+ | Then, you can visit [http://localhost:8080/PROJECT_NAME/zk/test http://localhost:8080/PROJECT_NAME/zk/foo] to request the richlet. | ||
+ | |||
+ | The URL specified in the <code>url-pattern</code> element must start with <code>/</code>. If the URI ends with <code>/*</code>, then it is matched to all request with the same prefix. To retrieve the request's actual URL, you can check the value returned by the <javadoc method="getRequestPath" type="interface">org.zkoss.zk.ui.Page</javadoc>. | ||
+ | |||
+ | =Version History= | ||
+ | |||
+ | {| border='1px' | width="100%" | ||
+ | ! Version !! Date !! Content | ||
+ | |- | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |} | ||
+ | |||
+ | {{ZKConfigurationReferencePageFooter}} |
Latest revision as of 04:09, 4 May 2022
DHtmlLayoutServlet
Location: WEB-INF/web.xml
[Required] Class: DHtmlLayoutServlet
ZK Loader is a servlet used to load ZUML pages when the Web server receives URL requests sent by the users.
Notice that you must specify load-on-startup
since many other servlets depend on the ZK loader.
<load-on-startup>1</load-on-startup>
Here is a complete sample.
The Initial Parameters
update-uri | [Required]
For example, if the ZK AU engine is mapped to Note: if the servlet container is used with other Web server, like Apache, you have to map this update URI to the servlet container (in additions to |
resource-uri |
Since 9.5.0 [Optional] It specifies the URI which the ZK Resource engine is mapped to. For example, if the ZK Resource engine is mapped to Note: if the servlet container is used with other Web server, like Apache, you have to map this resource URI to the servlet container (in additions to |
compress | [Optional][Default:true ]
|
log-level | [Optional]
It specifies the default log level for Possible values: |
Map URL to ZUML pages
It is suggested to map this servlet to the zul
and zhtml
extensions as shown below to process ZUML pages. It is OK if you want to prefer to use xul
and html
as the extension; just map them to ZK Loader too.
<servlet>
<description>ZK loader for evaluating ZUML pages</description>
<servlet-name>zkLoader</servlet-name>
<servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
<init-param>
<param-name>update-uri</param-name>
<param-value>/zkau</param-value>
</init-param>
<load-on-startup>1</load-on-startup><!-- MUST -->
</servlet>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zul</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zhtml</url-pattern>
</servlet-mapping>
Here is a complete sample.
Map URL to Richlets
Assume you have a richlet named foo.FooRichlet
. Then, you could configure it as follows.
First, declare the richlet:
<richlet>
<richlet-name>Foo</richlet-name>
<richlet-class>foo.FooRichlet</richlet-class>
</richlet>
Second, map the richlet to any number of URL you want:
<richlet-mapping>
<richlet-name>Foo</richlet-name>
<url-pattern>/foo</url-pattern>
</richlet-mapping>
<richlet-mapping>
<richlet-name>Fest</richlet-name>
<url-pattern>/some/more/*</url-pattern>
</richlet-mapping>
Notice that, by default, richlets are disabled. To enable them, add the following declaration to web.xml
. Once enabled, you can add as many as richlets as you want without modifying web.xml
any more. Of course, url-pattern
could be any pattern you prefer.
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>/zk/*</url-pattern><!-- any pattern you prefer -->
</servlet-mapping>
Then, you can visit http://localhost:8080/PROJECT_NAME/zk/foo to request the richlet.
The URL specified in the url-pattern
element must start with /
. If the URI ends with /*
, then it is matched to all request with the same prefix. To retrieve the request's actual URL, you can check the value returned by the Page.getRequestPath.
Version History
Version | Date | Content |
---|---|---|