Example code for path getComponent

From Documentation
Revision as of 02:57, 20 January 2022 by Hawk (talk | contribs) (correct highlight (via JWB))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Documentationxample code for path getComponent
xample code for path getComponent

Stop.png This documentation is for an older version of ZK. For the latest one, please click here.

Example of Path.getComponent

In the following code, when the button is clicked, its label will be changed.

<window id="w" apply="MyComposer">
	<button id="b" label="ok" forward="onClick=onChangeLabel"/>

And MyComposer.java

import org.zkoss.zk.ui.Path;
import org.zkoss.zk.ui.util.GenericComposer;
import org.zkoss.zul.Button;

public class MyComposer extends GenericComposer {
	Button btn = new Button();
	public void onChangeLabel(){
		btn = (Button)Path.getComponent("/w/b");

Another way, getFellow

getFellow is another api to get the component. But it is not recommended. For simplicity and consistency, use Path.getComponent instead.

omit Path.getComponent

Please refer to section Auto-wire the Components and Beans of the small talk : ZK MVC Made Easy. ZK has provided autowire feature, you can save your time and write less code.

Last Update : 2022/01/20

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.