XHTML Components
From Documentation
Revision as of 03:38, 17 May 2010 by Tmillsclare (talk | contribs) (Created page with '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 exampl…')
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"/>
Rather, you shall 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 ExecutionencodeURL method from org.zkoss.zk.ui.Execution.
<img id="another"/>
<zscript>
another.setDynamicAttribute("href",
Executions.getCurrent().encodeURL("/my/good.png"));
</zscript>
Notice that XUL components and all ZK features that accept an URL will invoke the encodeURL method automatically[1].
Notes
- ↑ The reason not to handle XHTML compoents is that we don't know which attribute requires URL.