0

Using Spring with ZK

asked 2009-01-29 15:06:16 +0800

YamilBracho gravatar image YamilBracho
1722 2

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 ?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-01-29 15:37:58 +0800

YamilBracho gravatar image YamilBracho
1722 2

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...

link publish delete flag offensive edit

answered 2010-09-16 21:42:03 +0800

hemin gravatar image hemin
3

I get it. thanks!

link publish delete flag offensive edit

answered 2016-05-30 05:26:42 +0800

arcangelSalazar gravatar image arcangelSalazar
36 2

You can also add this annotation:

@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)

Before your class definition and them use:

@WireVariable private AfiliacionService afiliacionService;

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

RSS

Stats

Asked: 2009-01-29 15:06:16 +0800

Seen: 261 times

Last updated: May 30 '16

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