0

Autowire Spring bean in ZK controller

asked 2014-10-01 09:37:43 +0800

bask gravatar image bask
1

Autowire not working after upgrading from 5.0.11

    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zul</artifactId>
        <version>7.0.3</version>
    </dependency>
    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zkplus</artifactId>
        <version>7.0.3</version>
    </dependency>
    <dependency>
        <groupId>org.zkoss.zk</groupId>
        <artifactId>zk</artifactId>
        <version>7.0.3</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.1.0.RELEASE</version>
    </dependency

Controller

public class SampleWebController extends GenericForwardComposer{    

private Sample sampleImp;

private Grid gridList;

@Override
public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);
    comp.setAttribute("controller", this);

    gridList.setModel(new SimpleListModel(sampleImp.getValues()));
}

}

Interface

public interface Sample {

List<String> getValues();

}

Spring bean

@Scope(value=BeanDefinition.SCOPE_SINGLETON)
@Service
public class SampleImp implements Sample {

public List<String> getValues() {
    List<String> list = new ArrayList<String>();
    list.add("one");
    list.add("two");
    return list;
}

}

Spring Config

<context:annotation-config />

    <context:component-scan base-package="com.firstppm" />
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-10-02 11:04:16 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2014-10-02 11:06:01 +0800

in zul:

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

in java composer:

@WireVariable
private Sample sampleImp;

or without zul:

@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
public class SampleWebController extends GenericForwardComposer{
. . .
@WireVariable
private Sample sampleImp;

best Stephan

link text

link publish delete flag offensive 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

Follow
1 follower

RSS

Stats

Asked: 2014-10-01 09:37:43 +0800

Seen: 39 times

Last updated: Oct 02 '14

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