Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZK - inject Spring beans directly into ZK beans

Tags:

spring

zk

Is it possible to inject Spring beans directly into ZK backing beans?

In tutorials such as this I've found only an example, where application context was extracted manually from web application complex, which very unelegant and unflexible.

like image 217
Danubian Sailor Avatar asked Dec 09 '25 15:12

Danubian Sailor


1 Answers

In fact, the VariableResolver is working, it is however hard to find, how to use it properly.

First, I had to include header in .zul file:

<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>

Then, use ${controllerBeanName} in apply attribute, f.e.

<window id="win" title="Typy mieszkań" width="750px" border="normal"
      apply="${appartmentTypeController}">

In my case, appartmentTypeController is bean extending GeneralForwardComposer, defined in spring context.

like image 85
Danubian Sailor Avatar answered Dec 11 '25 14:12

Danubian Sailor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!