XHTML Components"

From Documentation
m
m
Line 1: Line 1:
All XHTML components are derived from the org.zkoss.zhtml.impl.AbstractTag class.
+
All XHTML components are derived from <javadoc>org.zkoss.zhtml.impl.AbstractTag</javadoc>.
  
A XHTML component is a thin wrapper that encapsulates a native HTML tag. It is different from a XUL component or other none-native component in several ways.
+
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.
  
By implementing the org.zkoss.zk.ui.ext.RawId interface, the universal identifier (getUuid) is the same as the identifier (getId).
+
* 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>.
By implementing the org.zkoss.zk.ui.ext.DynamicAttributes interface, all XHTML components support arbitrary attributes. In other words, any attribute name is legal (as long as the targeted browser supports).
+
* 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).
  
===URLs===
+
===Encoding URLs===
  
 
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 "").
 
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 "").

Revision as of 03:45, 17 May 2010

All XHTML components are derived from AbstractTag.

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.

  • By implementing the RawId interface, the universal identifier, getUuid, is the same as the identifier getId.
  • By implementing the DynamicAttributes interface, all XHTML components support arbitrary attributes. In other words, any attribute name is legal (as long as the targeted browser supports).

Encoding URLs

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 "").

 <img href="/my/good.png"/>

Instead, you should use the encodeURL function in EL expressions as follows.


 <?taglib uri="http://www.zkoss.org/dsp/web/core.dsp.tld" prefix="p"?>
 ...
 <img href="${p:encodeURL('/my/good.png')}"/>

In Java, you should use the method, Execution.encodeURL(String).


 <img id="another"/>
 <zscript>
   another.setDynamicAttribute("href",
     Executions.getCurrent().encodeURL("/my/good.png"));
 </zscript>

Notice that XUL components and all ZK features that accept a URL will invoke the encodeURL method automatically. The reason why we do not handle XHTML components is that we do not know which attribute requires a URL.