services are null in spring controller with ZK

asked 2012-06-12 17:11:53 +0800

kossel gravatar image kossel

I'm trying to integrate zk with spring, but for somehow I can't make spring instances those service/manage objects :S

Controller, ProductTypecontroller:

    public class ProductTypeController extends SelectorComposer {

        private ProductTypeService productTypeService;

        @Listen("onCreate = listbox#typeList")
        public void loadAll() {
            BindingListModelList model = new BindingListModelList(productTypeService.getAll(), false);
            typeList.setItemRenderer(new ProductTypeListRenderer());

       public void loadAll2(Listbox lb){
         List lista = productTypeService.getAll();
        BindingListModelList model = new BindingListModelList(lista, false);
        lb.setItemRenderer(new ProductTypeListRenderer());


the Zul
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
    <div id="winDiv" apply="com.iknition.micutecake.controller.ProductTypeController">
            <listbox id="typeList" width="450px" height="300px" >
                    <listheader width="50px" label="id" sort="auto(id)" />
                    <listheader width="250px" label="name" sort="auto(name)" />
                    <listheader width="140px" label="description" sort="auto(description)" />

I get NullPointerException because productTypeSerivce is null.

however, if I add

to the listbox line in .zul then it will call the method
 loadAll2(Listbox lb)
in that way, productTypeService is not null, and everything works fine.

any idea why? or how to make it work?

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-07-24 01:46:05 +0800

paowang gravatar image paowang
140 6

check this: http://www.zkoss.org/product/zkspring

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




Asked: 2012-06-12 17:11:53 +0800

Seen: 148 times

Last updated: Jul 24 '12

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