Revision history [back]

click to hide/show revision 1
initial version

answered 2018-03-13 16:15:33 +0800

cor3000 gravatar image cor3000

I hope this runnable example explains how this can be done: http://zkfiddle.org/sample/3971936/4-Global-Command-Navigation-with-Params

The non obvious part is the "specialty" about <include> that it is only reloading when the url changes ... you might start a fake url parameter but I'd recommend against is, since <include> behaves differently when using url parameters - just to change the src (defer mode has all sorts of side effects you don't want to be worried about). So it's clearer to simply reset the src to null for an instant and force a re-render of the include like that.

Parameters passed into an <include> can be accessed with the @ExecutionArgParam annotation.

I suggest sticking to a single "data" parameter which can be any java object and hence contain arbitrarily complex navigation information.

ZK-EE users should use the <apply>-shadow-element which doesn't require the forceReload approach e.g.:

<apply templateURI="@load(navVM.page)" data="@load(navVM.data)"/>

I hope this runnable example explains how this can be done: http://zkfiddle.org/sample/3971936/4-Global-Command-Navigation-with-Params

The non obvious part is the "specialty" about <include> that it is only reloading when the url changes ... you might start a fake url parameter but I'd recommend against is, since <include> behaves differently when using url parameters - just to change the src (defer mode has all sorts of side effects you don't want to be worried about). So it's clearer to simply reset the src to null for an instant and force a re-render of the include like that.

Parameters passed into an <include> can be accessed with the @ExecutionArgParam annotation.

IMPORTANT: the order of parameters in the zul and when calling postNotifyChange matters. <include> needs to receive the data before changing the src-attribute (or it will re-render with the previous value) <include data="@load(navVM.data)" src="@load(navVM.page)"/>

BindUtils.postNotifyChange(null, null, this, "data");
BindUtils.postNotifyChange(null, null, this, "page");

I suggest sticking to a single "data" parameter which can be any java object and hence contain arbitrarily complex navigation information.

ZK-EE users should use the <apply>-shadow-element which doesn't require the forceReload approach e.g.:

<apply templateURI="@load(navVM.page)" data="@load(navVM.data)"/>

With <apply> the parameter order doesn't matter.

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