0

Can I use an include inside an hbox in zk? [closed]

asked 2019-10-17 17:32:02 +0800

Matthias84 gravatar image Matthias84
3 2

updated 2019-10-17 17:34:49 +0800

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?

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by cor3000
close date 2019-10-21 18:38:57

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-10-18 17:17:14 +0800

cor3000 gravatar image cor3000
4887 2 7
ZK Team

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"/>
link publish delete flag offensive edit

Comments

Question tools

Follow
1 follower

RSS

Stats

Asked: 2019-10-17 17:32:02 +0800

Seen: 8 times

Last updated: Oct 18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More