ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

Server side retrieval of the currently rendered html for a certain component

cvarona
3 Feb 2012 09:12:25 GMT
3 Feb 2012 09:12:25 GMT

Hi there,

I'd like to know whether there is some way to obtain the html generated for a given component, say a window, from the server side.

With kind regards

César Varona

benbai
9 Feb 2012 07:05:17 GMT
9 Feb 2012 07:05:17 GMT

Hi Varona,

You can try to send it to server side from client side, for example,
the fragment below will show the window's html in server console

<zk>
	<script type="text/javascript">
		function getHtml(id) {
			var node = jq('#'+id)[0],
				div = document.createElement('div'),
				$tmp = jq('$tmp'),
				tmp = $tmp[0];
			div.appendChild(node.cloneNode(true));
			$tmp.focus();
			tmp.value = div.innerHTML;
			$tmp.blur();
			tmp.value = '';
		}
	</script>
	<window id="win" title="test win" />
	<textbox id="tmp" onChange="System.out.println(event.getValue());" visible="false" />
	<button label="show window html in console">
		<attribute name="onClick">
			Clients.evalJavaScript("getHtml('"+win.getUuid()+"');");
		</attribute>
	</button>
</zk>

Regards,
ben

cvarona
9 Feb 2012 10:07:16 GMT
9 Feb 2012 10:07:16 GMT

Thanks a lot for this, it rocks!

César Varona