XHTML Components"

From Documentation
m
m (Undo revision 18989 by Malta (talk))
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
All XHTML components are derived from <javadoc>org.zkoss.zhtml.impl.AbstractTag</javadoc>.
+
{{ZKComponentReferencePageHeader}}
  
An XHTML component is a thin wrapper that encapsulates a native HTML tag. It is different to a XUL component or other none-native component in several ways.
+
This section describes how to use the [[ZUML Reference/ZUML/Languages/XHTML|XHTML component set]] (i.e., XHTML components). XHTML components are in a different component set than [[ZUML Reference/ZUML/Languages/ZUL|ZUL components]]. You have to [[ZUML Reference/ZUML/Languages|specify XML namespace]] to distinguish them if you want to use them in the same ZUML document. For example,
  
* By implementing the <javadoc type="interface">org.zkoss.zk.ui.ext.RawId</javadoc> interface, the universal identifier, <mp>getUuid</mp>, is the same as the identifier <mp>getId</mp>.
+
<source lang="xml">
* By implementing the <javadoc type="interface">org.zkoss.zk.ui.ext.DynamicAttributes</javadoc> interface, all XHTML components support arbitrary attributes. In other words, any attribute name is legal (as long as the targeted browser supports).
+
<window xmlns:h="xhtml">
 
+
    <h:ul>
===Encoding URLs===
+
        <h:li>Click <button/></h:li>
 
+
    </h:ul>
A XHTML component generates attributes directly to native HTML tags. It means, unlike XUL, it doesn't prefix the servlet context path to attributes for specifying URL. For example, the following codes don't work (unless the servlet context is "").
+
</window>
 
 
<source lang="xml" >
 
<img href="/my/good.png"/>
 
 
</source>
 
</source>
  
Instead, you should use the <mp>encodeURL</mp> function in EL expressions as follows.
+
Notice that the HTML component set is one of the approaches to use HTML tags directly in a ZUML document. In most cases, it is not the best approach. For information please refer to [[ZK Developer's Reference/UI Patterns/HTML Tags|ZK Developer's Reference: HTML tags]].
  
 +
{{ZKComponentReferenceHeadingToc}}
  
<source lang="xml" >
+
{{ZKComponentReferencePageFooter}}
<?taglib uri="http://www.zkoss.org/dsp/web/core.dsp.tld" prefix="p"?>
 
...
 
<img href="${p:encodeURL('/my/good.png')}"/>
 
</source>
 
 
 
In Java, you should use the method, <javadoc method="encodeURL(java.lang.String)">org.zkoss.zk.ui.Execution</javadoc>.
 
 
 
 
 
<source lang="xml" >
 
<img id="another"/>
 
<zscript>
 
  another.setDynamicAttribute("href",
 
    Executions.getCurrent().encodeURL("/my/good.png"));
 
</zscript>
 
</source>
 
 
 
Notice that XUL components and all ZK features that accept a URL will invoke the <mp>encodeURL</mp> method automatically. The reason why we do not
 
handle XHTML components is that we do not know which attribute requires a URL.
 

Latest revision as of 00:31, 16 June 2011


XHTML Components

This section describes how to use the XHTML component set (i.e., XHTML components). XHTML components are in a different component set than ZUL components. You have to specify XML namespace to distinguish them if you want to use them in the same ZUML document. For example,

<window xmlns:h="xhtml">
    <h:ul>
        <h:li>Click <button/></h:li>
    </h:ul>
</window>

Notice that the HTML component set is one of the approaches to use HTML tags directly in a ZUML document. In most cases, it is not the best approach. For information please refer to ZK Developer's Reference: HTML tags.





Last Update : 2011/06/16

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