-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
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...
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.
Asked: 2018-10-17 22:09:02 +0800
Seen: 6 times
Last updated: Oct 23 '18
Thanks cor 3 thousand ;)
jgomer2001 ( 2018-10-25 04:55:58 +0800 )edityou're welcome :)
cor3000 ( 2018-10-25 12:25:53 +0800 )edit