The Component Path

Like a path in a file system, a component path is a catenation of IDs of components along ID spaces. In the above example, the path will be "/A/B/C". In other words, the root of a component path is the current page. If you want to identity another page, you have to use "//". In the above example, the path can also be expressed as "//P/A/B/C".

The org.zkoss.zk.ui.Path class is, like java.io.File, provided to simplify the manipulation of component paths. Thus, the following statement is equivalent to the above example.

Path.getComponent("/A/B/C"); //assume the current page is P
Path.getComponent("//P/A/B/C");

In addition to static methods, you could instantiate a Path instance.

Path parent = new Path("//P/A");
new Path(parent, "B/C").getComponent();

Tip: Path.getComponent("//xyz") always returns null, since the identifier following // is the page's ID. And, page is not component.