when setting the src attribute of an xhtml component before it is added to a page will ignore it and default to "", losing the src url
<zk xmlns:x="xhtml"> <div id="container"> </div> <zscript><![CDATA[ import org.zkoss.zhtml.Img; Img img = new Img(); img.setDynamicProperty("src", "/some/url.jpg"); img.setParent(container); //workaround: set the src after adding the component //img.setDynamicProperty("src", "/some/url.jpg"); ]]></zscript> </zk>
Workaround
set the src attribute after setting the parent
or use the Image component:
org.zkoss.zul.Image which supports setting the src before appending the component correctly