The native Namespace"

From Documentation
(Created page with '{{ZKDevelopersReferencePageHeader}} =Overview= With the native namespace, a XML element in a ZUML document will be interpreted as a nat…')
 
Line 32: Line 32:
 
where <tt><input></tt> is the HTML tag(s) generated by the <tt>textbox</tt> component. Unlike <tt>textbox</tt> in the example above, ZK Loader doesn't really create a component for each of <tt>ul</tt> and <tt>li</tt>.<ref>ZK ZK actually creates a special component to represent as many XML elements with the native namespace as possible.</ref> Rather, they are sent to the client directly. Of course, they must be recognizable by the client. For a HTML browser, they must be the valid HTML tags.
 
where <tt><input></tt> is the HTML tag(s) generated by the <tt>textbox</tt> component. Unlike <tt>textbox</tt> in the example above, ZK Loader doesn't really create a component for each of <tt>ul</tt> and <tt>li</tt>.<ref>ZK ZK actually creates a special component to represent as many XML elements with the native namespace as possible.</ref> Rather, they are sent to the client directly. Of course, they must be recognizable by the client. For a HTML browser, they must be the valid HTML tags.
  
Since the elements associated with the Native namespace are sent directly to the client, they are not ZK components, and they don't have the counterpart at the client. The advantage is the better performance in term of both memory and processing time. On the other hand, the disadvantage is you cannot access or change them dynamically. For example, the following code snippet is incorrect, since there is no component called <tt>x</tt>.
+
=Pros and Cons=
 +
 
 +
The XML elements associated with the native namespace will be considered as tags that the client accepts, and they are sent directly to the client to display. They are not ZK components, and they don't have the counterpart (widget) at the client. The advantage is the better performance in term of both memory and processing time.
 +
 
 +
However, the disadvantage is you cannot access or change them dynamically. For example, the following code snippet is incorrect, since there is no component called <tt>x</tt>.
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 39: Line 43:
 
</source>
 
</source>
 
   
 
   
If you want to change them dynamically, you can specify the XHTML namespace as described in the following section.
+
If you want to change them dynamically, you could use the components from the [[ZUML Reference/ZUML/Languages/XHTML|XHTML component set]] as described in the following section.
  
'''Notes'''
+
<blockquote>
 +
---
 
<references/>
 
<references/>
 
+
</blockquote>
  
 
= Output Another Namespace with the Native Namespace =
 
= Output Another Namespace with the Native Namespace =

Revision as of 11:28, 10 November 2010


The native Namespace


Overview

With the native namespace, a XML element in a ZUML document will be interpreted as a native tag that shall be sent to the browser directly, rather than becoming a ZK component.

For example,

 <n:ul xmlns:n="http://www.zkoss.org/2005/zk/native">
     <n:li>
     <textbox/>
     </n:li>
     <n:li>
     <textbox/>
     </n:li>
 </n:ul>

will attach the following HTML tags to the browser's DOM tree:

 <ul>
     <li>
     <input id="z_a3_2"/>
     </li>
     <li>
     <input id="z_a3_5"/>
     </li>
 </ul

where <input> is the HTML tag(s) generated by the textbox component. Unlike textbox in the example above, ZK Loader doesn't really create a component for each of ul and li.[1] Rather, they are sent to the client directly. Of course, they must be recognizable by the client. For a HTML browser, they must be the valid HTML tags.

Pros and Cons

The XML elements associated with the native namespace will be considered as tags that the client accepts, and they are sent directly to the client to display. They are not ZK components, and they don't have the counterpart (widget) at the client. The advantage is the better performance in term of both memory and processing time.

However, the disadvantage is you cannot access or change them dynamically. For example, the following code snippet is incorrect, since there is no component called x.

 <n:ul id="x" xmlns:n="http://www.zkoss.org/2005/zk/native"/>
 <button label="add" onClick="new Li().setParent(x)"/>

If you want to change them dynamically, you could use the components from the XHTML component set as described in the following section.

---

  1. ZK ZK actually creates a special component to represent as many XML elements with the native namespace as possible.

Output Another Namespace with the Native Namespace

If you want to generate another namespace to the output, you can use another format as the URI of the Native namespace:

 native:''URI-of-another-namespace''

For example, if you want to output the XAML tags directly to the client, you can specify native:http://schemas.microsoft.com/client/2007 as follows.

<zk>
	<Canvas xmlns="native:http://schemas.microsoft.com/client/2007">
	  <TextBlock>Hello World!</TextBlock>
	</Canvas>
</zk>

Then, the client will receive the following[1]:

<div z.au="/ZKTester/zkau" z.zidsp="page" style="width: 100%; height: 100%;" z.dtid="gk68" id="z_k6_0" class="zk">
     <canvas xmlns="http://schemas.microsoft.com/client/2007">
          <textblock>Hello World!</textblock>
     </canvas>
</div>

Notes

  1. The real HTML output of window depends on its implementation. Here is only a simplified version.

Version History

Last Update : 2010/11/10

Version Date Content
     


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