Alternative content for include [closed]

asked 2018-10-17 22:09:02 +0800

jgomer2001 gravatar image jgomer2001
80 2


In my app I have to do includes specifying variable src values, e.g.

<include src="@load(...)" />

Actual values depend on user input, so sometimes, they can point to an inexisting resource, thus, taking to an error page

I'm using ZK CE 8.5. I would like to know if there is some way for handling the case of inexisting resource, like providing fallback content when the include fails so I can prevent the whole page (the one with the includes) to crash...

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 2018-10-25 12:26:05


Thanks cor 3 thousand ;)

jgomer2001 ( 2018-10-25 04:55:58 +0800 )edit

you're welcome :)

cor3000 ( 2018-10-25 12:25:53 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-10-23 12:38:08 +0800

cor3000 gravatar image cor3000
4466 2 7
ZK Team

updated 2018-10-23 12:40:38 +0800

you can check if the zul actually exists before updating the src attribute. demonstrated in this example: http://zkfiddle.org/sample/3en56to/1-check-existing-include-src

It shows 2 alternatives ... both cases check for the existence of the pageDefinition which is the internal representation of a parsed zul file in ZK.

One option simply checks for an exception, the other actually retrieves the page definition so you can do a null check. And set a sanitizedIncludeSrc.

Thus you don't have to deal with incorrect zul url applied to the include component, because it will receive correct values.

link publish delete flag offensive edit

Question tools

1 follower



Asked: 2018-10-17 22:09:02 +0800

Seen: 5 times

Last updated: Oct 23 '18

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