ZK SpringBoot @WireVariable not working

asked 2021-09-26 21:16:47 +0800

franferri gravatar image franferri
48 2

I'm using ZK SpringBoot, trying to have in the SelectorComposer the @Autowired stuff that I'm able to use in the SpringController.


This example don't work:

public class UsersComposer extends SelectorComposer<Window> {
    private List<User> users;

    public ListModel<User> getUsers() {
        return new ListModelList<User>(users);

In my own code I'm using the following:

public class PartialProductDetailsRead extends SelectorComposer<Grid> {

    private ConfigProperties configProperties;

    private RestTemplate restTemplate;


Then I'm calling the wired stuff on my:

public ComponentInfo doBeforeCompose(Page page, Component parent, ComponentInfo compInfo) {

configProperties is always null.

What I'm doing wrong?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2021-09-27 09:34:29 +0800

cor3000 gravatar image cor3000
6280 2 7

Doesn't look wrong by itself and the question is: What does it do?

To verify ZK's variable resolver is doing what it's supposed to do you can simply place a breakpoint into DelegatingVariableResolver.resolveVariable().


ZK should call this method in order to resolve the variables "configProperties" and "restTemplate" (by Name - ZK doesn't try to wire by type). Then a few lines into debugging it should call Spring's applicationContext.getBean() for a bean by that name.

https://github.com/zkoss/zk/blob/master/zkplus/src/org/zkoss/zkplus/spring/DelegatingVariableResolver.java#L162-L169 https://github.com/zkoss/zk/blob/master/zkplus/src/org/zkoss/zkplus/spring/SpringUtil.java#L54

If spring returns null - i.e. no spring bean exists by that name - then you know you need to configure the bean id/name or alias in your spring config to make it visible to ZK's WireVariable, or rename the variable accordingly in your SelectorComposer or specify the name @WireVariable("the_correct_bean_name") . If it fails otherwise or doesn't get called at all, we might be able to help from the ZK side.

link publish delete flag offensive edit

answered 2021-09-27 22:46:24 +0800

franferri gravatar image franferri
48 2

Worked, cor3000 you rock tons!




did the trick

link publish delete flag offensive edit


thanks for getting back!

cor3000 ( 2021-09-28 12:41:30 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2021-09-26 21:16:47 +0800

Seen: 14 times

Last updated: Sep 27 '21

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