XHTML Components"

From Documentation
m (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…')
 
m
Line 5: Line 5:
 
</source>
 
</source>
  
Rather, you shall use the <tt>encodeURL</tt> function in EL expressions as follows.
+
Instead, you should use the <mp>encodeURL</mp> function in EL expressions as follows.
  
  
Line 14: Line 14:
 
</source>
 
</source>
  
In Java, you should use <javadoc>org.zkoss.zk.ui.Execution</javadoc><tt>encodeURL</tt> method from <tt>org.zkoss.zk.ui.Execution</tt>.
+
In Java, you should use the method, <javadoc method="encodeURL(java.lang.String)">org.zkoss.zk.ui.Execution</javadoc>.
  
  
Line 25: Line 25:
 
</source>
 
</source>
  
Notice that XUL components and all ZK features that accept an URL will invoke the <tt>encodeURL</tt> method automatically<ref> The reason not to  
+
Notice that XUL components and all ZK features that accept a URL will invoke the <mp>encodeURL</mp> method automatically <ref>The reason not to  
 
handle XHTML compoents is that we don't know which attribute requires URL.</ref>.
 
handle XHTML compoents is that we don't know which attribute requires URL.</ref>.
  
 
'''Notes'''
 
'''Notes'''
 
<references/>
 
<references/>

Revision as of 03:40, 17 May 2010

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 [1].

Notes

  1. The reason not to handle XHTML compoents is that we don't know which attribute requires URL.