Description & Source Code

This example demonstrates the straight forward event listening mechanism in ZK.
The textboxes are registered with the onFocus and onBlur events such that the changeStyle method is called whenever the two events are triggered, which highlights the text label in light blue. The demo also shows how buttons in the configuration can be delegated to trigger the textboxes' focus event.

	<hbox id="h1">
		<label id="t1" value="Text1: " />
		<textbox id="text1" onBlur="changeStyle(h1)" onFocus="changeStyle(h1)" />
	<hbox id="h2">
		<label id="t2" value="Text2: " />
		<textbox id="text2" onBlur="changeStyle(h2)" onFocus="changeStyle(h2)" />
	<style dynamic="true">
		.focus .z-label {
			color: #029CCC;
		void changeStyle(Hbox h) {
			h.sclass = "focus".equals(h.sclass)? "" : "focus";
		<button label="Focus on Text1" onClick="text1.focus();" />
		<button label="Focus on Text2" onClick="text2.focus();" />