-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have a service taht I would like to use in a composer class. This composer is associate to a zul page
I did:
private AfiliacionService servicio; ... public ListAfiliacionEditComposer() { servicio = (AfiliacionService) SpringUtil.getBean("afiliacionService"); ... Source Code
But i would like to handle this via injection in my applicationContext.xml..
Any hint ?
I did..!
It so easy, here the steps:
1) Create ten entry for your composer in the applicationContext.xml or spring xml configuration file. Note that my composer needs a
service class (AfiliacioNService).
<bean id="listAfiliacionEditController" class="bcv.cce.domiciliacion.empresa.ui.ListAfiliacionEditComposer" scope="prototype"> <constructor-arg index="0" ref="afiliacionService" /> </bean>
2) Add to your zul page at the begining
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
3) Change the apply attribute to the name of your spring bean (pass 1):
apply="${listAfiliacionEditController}"
4) Then I change my composer constructor:
public ListAfiliacionEditComposer(AfiliacionService servicio) {
Note that "servicio" is injected by Spring...
You can also add this annotation:
@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
Before your class definition and them use:
@WireVariable private AfiliacionService afiliacionService;
Asked: 2009-01-29 15:06:16 +0800
Seen: 261 times
Last updated: May 30 '16