0

Alternative content for include [closed]

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

jgomer2001 gravatar image jgomer2001
80 4

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...

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

Comments

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
0

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

cor3000 gravatar image cor3000
6280 2 7

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

Follow
1 follower

RSS

Stats

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

Seen: 6 times

Last updated: Oct 23 '18

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