Use Native Namespace instead of XHTML Namespace

From Documentation
Revision as of 05:22, 15 October 2010 by Tomyeh (talk | contribs) (Created page with '{{ZKDevelopersReferencePageHeader}} As described in the [http://books.zkoss.org/wiki/Work_with_HTML_Tags '''Work with HTML Tags'''] section of the '''ZUML with the XUL Component…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


DocumentationZK Developer's ReferencePerformance TipsUse Native Namespace instead of XHTML Namespace
Use Native Namespace instead of XHTML Namespace


As described in the Work with HTML Tags section of the ZUML with the XUL Component Set chapter, ZK creates a ZK component for each XML element specified with the XHTML namespace. In other words, ZK has to maintain their states at the server. Since the number of HTML tags are usually large, the performance will be improved dramatically if you use the Native namespace instead.

For example, the following code snippet creates five components (one table, tr, textbox and two td).

<syntax lang="xml" > <h:table xmlns:h="http://www.w3.org/1999/xhtml">

   <h:tr>
       <h:td>Name</h:td>
       <h:td>
       <textbox/>
       </h:td>
   </h:tr>

</h:table> </syntax>

On the other hand, the following code snippet creates two components (one special component to generate table, tr and td to the client, and one textbox).

<syntax lang="xml" > <n:table xmlns:n="native">

   <n:tr>
       <n:td>Name</n:td>
       <n:td>
       <textbox/>
       </n:td>
   </n:tr>

</n:table> </syntax>

Notice that table, tr and td are generated directly to the client, so they don't have no counterpart at the client. Thus, you can not change it dynamically. For example, the following code snippet is incorrect.

<syntax lang="xml" > <n:ul id="x" xmlns:n="native"/> <button label="add" onClick="new Li().setParent(x)"/> </syntax>

Rather, you have to use the html component or the XHTML namespace, if you want to change dynamically.

Version History

Version Date Content
     



Last Update : 2010/10/15

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