Processing...
Description & Source Code

ZK iframe allows developer to set its content, such as images and audio, directly, in addition to URLs. Developers could leverage this feature to generate contents dynamically; for example, a PDF report generated by JasperReports.

iframe.zul
<iframe id="iframe" src="https://www.zkoss.org" 
	width="100%" height="400px" style="border: 1px solid gray" />
		
iframe_ctrl.zul
<zk>
	<label value="upload a jpg, jpeg, png, gif or bmp"/>
	<button upload="true" label="Select File">
		<attribute name="onUpload"><![CDATA[
			Object media = event.getMedia(); // item per item declaration due to BSH limitations
			List supportedFormats = new ArrayList();
			supportedFormats.add("jpg");
			supportedFormats.add("jpeg");
			supportedFormats.add("png");
			supportedFormats.add("gif");
			supportedFormats.add("bmp");
			/* check if for image and for matching file extension*/
			if (!media.getContentType().startsWith("image/") || -1 == supportedFormats.indexOf(media.getFormat())) {
				Clients.showNotification("Please upload a jpg, jpeg, png, gif or bmp file");
				return;
			}
			if (media != null)
				iframe.setContent(media);
		]]></attribute>
	</button>
</zk>