same answer accepted on stackoverflow https://stackoverflow.com/questions/58428805/can-i-use-an-include-inside-an-hbox-in-zk/58447740#58447740
cor3000 ( 2019-10-21 18:38:15 +0800 )edit-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have the following code in my zul:
<hbox>
<include src="firstInclude.zul" />
<include src="secondInclude.zul" />
</hbox>
I keep getting a page-not-found error for firstInclude.zul. The firstInclude.zul file is in the same directory as the file containing the code depicted above. The zul file containing the code above, on the other hand, is dynamically included into a modal window. The window's viewmodel is performing this task. What am I doing wrong?
Relative include paths are resolved based to the current desktop's path (which is the location of the main.zul
currently displayed).
If you want to check this in code place a breakpoint in AbstractExecution:toAbsolutePath() and observe which uri
is passed in and which currentDirectory
is prepended.
(This process is independent of any components, so <hbox>
has nothing to do with it. Also this is independent of dynamic usage.)
Assume this static structure:
/pages/main.zul
/pages/sub/sub.zul
/pages/sub/sub-include.zul
main.zul
<div>
<include src="sub/sub.zul"/>
</div>
sub/sub.zul
<div>
SUB
<div>
<include src="sub-include.zul"/>
</div>
</div>
Will result in this error:
org.zkoss.zk.ui.UiException: Page not found: /pages/sub-include.zul
at org.zkoss.zk.ui.http.ExecutionImpl.getPageDefinition(ExecutionImpl.java:385)
at org.zkoss.zul.Include.afterCompose(Include.java:509)
...
Changing the included src url like below will fix this issue.
<include src="sub/sub-include.zul"/>
I agree this is not obvious, but that's how it behaves.
A more robust alternative is to use absolute paths (starting with a /
) to avoid relative path resolution issues.
<include src="/pages/sub/sub-include.zul"/>
same answer accepted on stackoverflow https://stackoverflow.com/questions/58428805/can-i-use-an-include-inside-an-hbox-in-zk/58447740#58447740
cor3000 ( 2019-10-21 18:38:15 +0800 )editAsked: 2019-10-17 17:32:02 +0800
Seen: 8 times
Last updated: Oct 18 '19