-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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" />
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
Asked: 2014-10-01 09:37:43 +0800
Seen: 45 times
Last updated: Oct 02 '14