The device-config Element"

From Documentation
(Replaced content with '{{ZKConfigurationReferencePageHeader}} {{ZKConfigurationReferenceHeadingToc}} ==Version History== {| border='1px' | width="100%" ! Version !! Date !! Content |- |   …')
Line 1: Line 1:
 
{{ZKConfigurationReferencePageHeader}}
 
{{ZKConfigurationReferencePageHeader}}
  
__TOC__
+
  {{ZKConfigurationReferenceHeadingToc}}
It specifies a device. A device represents a client. Different clients have different implementation. Currently there are two types: <tt>ajax</tt> and <tt>mil</tt>. They represents the Web browsers with Ajax, and the mobile device with Mobile Interactive Language<ref>MIL is a ZK markup language used to communicate with the mobile devices.</ref>. It is used to create an instance returned by the <tt>getDevice</tt> method of the <tt>Desktop</tt> intereface.
 
 
 
The allowed child element is <tt>device-type</tt> , <tt>device-class</tt>, <tt>timeout-uri</tt>, and <tt>unavailable-message</tt>. You might have multiple <tt>device-config</tt> elements in one <tt>zk.xml</tt>.
 
 
 
<source lang="xml" >
 
  <device-config>
 
    <device-type>ajax</device-type>
 
    <device-class>my.MyAjaxDevice</device-class>
 
    <timeout-uri>/my-timeout.zul</timeout-uri>
 
    <server-push-class>my.ServerPush</server-push-class>
 
    <unavailable-message><![CDATA[
 
<p style="color:red">Sorry, JavaScript must be enabled in order for you to use KillApp.</p>
 
    ]]></unavailable-message>
 
    <embed><![CDATA[
 
<script type="text/javascript">
 
    AU_progressbar = function (id, msg) {
 
        Boot_progressbox(id, msg, 0, 0, true, true);
 
    };
 
</script>
 
    ]]></embed>
 
</device-config>
 
</source>
 
 
 
 
 
'''Note:''' Unlike most other configurations defined in <tt>WEB-INF/zk.xml</tt>, the definitions defined in <tt>device-config</tt> are applied to all Web applications sharing the same <tt>zk.jar</tt>. Refer to the <tt>zscript-config</tt> element for more information.
 
 
 
 
 
'''Notes'''
 
<references/>
 
 
 
 
 
 
 
== The device-class Element ==
 
[Optional]
 
 
 
It specifies the implementation class. The class must implement the <javadoc type="interface">org.zkoss.zk.device.Device</javadoc> interface. Instead of implementing it from scratch, you can derive from the proper implementation, such as <tt>AjaxDevice</tt> and <tt>MilDevice</tt>.
 
 
 
== The device-type Element ==
 
[Required]
 
 
 
It specifies the device type. The previous implementation with the same device type will be replaced if any.
 
 
 
== The embed Element ==
 
[Optional][Multiple]
 
 
 
It specifies the content that shall be added to the output generated and sent to the client when rendering a desktop. The syntax of the content depends on the client. For Ajax clients, it can be any tags that can be placed inside HTML <tt>HEAD</tt> tag, such as <tt>SCRIPT</tt>, <tt>META</tt> and others.
 
 
 
For example, if you want to show the progress bar in the center of the browser window, you can specify the following in <tt>zk.xml</tt>.
 
 
 
<source lang="xml" >
 
<device-config>
 
<device-type>ajax</device-type>
 
<embed><![CDATA[
 
<script type="text/javascript">
 
    AU_progressbar = function (id, msg) {
 
        Boot_progressbox(id, msg, 0, 0, true, true);
 
    };
 
</script>
 
    ]]></embed>
 
</device-config>
 
</source>
 
 
 
 
 
You can specify multiple <tt>embed</tt> elements and their content be concatenated together.
 
 
 
== The server-push-class Element ==
 
[Optional][Default: ''depends on device and what edition you use'']
 
 
 
It specifies which class used to implement the server-push feature. The class must have a default constructor (without any argument), and implement the <javadoc type="interface">org.zkoss.zk.ui.sys.ServerPush</javadoc> interface.
 
 
 
<source lang="xml" >
 
<device-config>
 
    <device-type>ajax</device-type>
 
    <server-push-class>my.ServerPush</server-push-class>
 
</device-config>
 
</source>
 
 
 
In addition to configuring the application's default implementation, you can choose an implement for a particular class by use of <javadoc method="enableServerPush(org.zkoss.zk.ui.sys.ServerPush)">org.zkoss.zk.ui.sys.DesktopCtrl</javadoc>. For example,
 
 
 
<source lang="java">
 
((DesktopCtrl)desktop).enableServerPush(new org.zkoss.zk.ui.impl.PollingServerPush());
 
</source>
 
 
 
== The timeout-uri Element ==
 
[Optional]
 
[Default: ''null'']
 
[Deprecated since 3.6.3, use [[ZK Configuration Reference/zk.xml/The session-config Element#The timeout-uri Element | session-config]] instead]
 
 
 
It specifies the target URI that will be used to redirect users to, when the desktop no longer exists – it is usually caused by session timeout. If this element is omitted, an error message will be shown up at the browser to alert users for what happens.
 
 
 
To reload the same URI again, you can specify an ''empty'' content as follows.
 
 
 
<source lang="xml" >
 
<device-config>
 
    <device-type>ajax</device-type>
 
    <timeout-uri></timeout-uri>
 
</device-config>
 
</source>
 
 
 
== The unavailable-message Element ==
 
[Optional][Default: ''depends on device'']
 
 
 
It specifies the message that will be displayed if the client doesn't support this device.
 
  
 
==Version History==
 
==Version History==

Revision as of 08:19, 3 December 2010


The device-config Element




Version History

Version Date Content
     



Last Update : 2010/12/03

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