Revision history [back]

click to hide/show revision 1
initial version

answered 2021-03-10 11:26:12 +0800

cor3000 gravatar image cor3000

ZK Team

How does zk know which one to use ? Does it attempt them one by one ?

yes it goes through the list of all variable resolvers. The first one returning the first non-null value.

You can add a breakpoint in PageImpl#getXelVariable to see what resolvers are defined at page level - and in which order they are processed.

There can be additional VariableResolvers not defined a page level that also take part in the variable resolution.

Also is it possible to explicitly state the resolver to use in a zul page for a particular component ?

In a page you define a specific VariableResolver (not per component) don't make your live harder than it has to be. Still you can add custom attributes for a specific component. There will be a built-in variable resolver also looking into the component scoped variables. Or you can split your zul code into multiple files having different variable-resolvers configured.

In the end it might just be that variable resolver isn't the perfect tool for your requirements/goals you're trying to achieve. In case you can give some details about those there is maybe a different way to implement those (e.g. the mentioned custom-attributes).

How does zk know which one to use ? Does it attempt them one by one ?

yes it goes through the list of all variable resolvers. The first one returning the first non-null value.

You can add a breakpoint in PageImpl#getXelVariable to see what resolvers are defined at page level - and in which order they are processed.

There can be additional VariableResolvers not defined a page level that also take part in the variable resolution.

Also is it possible to explicitly state the resolver to use in a zul page for a particular component ?

In a page you define a specific VariableResolver for the whole page (not per component) don't make your live harder than it has to be. component).

Still you can add custom attributes for a specific component. There will be a built-in variable resolver also looking into the component scoped variables. Or you can split your zul code into multiple files having different variable-resolvers configured.

In the end it might just be that variable resolver isn't the perfect tool for your requirements/goals you're trying to achieve. In case you can give some details about those there is maybe a different way to implement those (e.g. the mentioned custom-attributes).

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