我的程序人生

ZK spring 当中@EventHandler不能生效的解决方案

最次换新东家。公司的管理系统用的是zk,而我又是喜欢使用spring的。
对于第一次使用zk,看了一次文档后,就想使用其自身提供的zk与spring的组合了。
所有的配置也完成了,但在@EventHandler上就是不生效
添加的事件不启动。看过源码后。
发现GenericSpringComposer.java当中
private void processEventsAnnotation(Component comp, String annotationValue, String mdname) {
        
if (annotationValue == null) {
            
return;
        }
        List
<String> annotationValueTokens = (List<String>) CollectionsX.parse(new ArrayList<String>(), annotationValue, ',');
        
for (String annotationValueToken : annotationValueTokens) {
            String srccompid 
= annotationValueToken.substring(0, annotationValueToken.indexOf('.'));
            String srcevt  
= annotationValueToken.substring(annotationValueToken.indexOf('.'+ 1, annotationValueToken.length());
            String eventName 
= srcevt + "." + srccompid;
            
Object o = SpringUtil.getBean(srccompid);
            
if(o instanceof Component) {
                Component c 
= (Component) o;
                List
<String> methodNames = eventsMap.get(eventName); 
                
if(methodNames == null) {
                    methodNames 
= new ArrayList<String>();
                    methodNames.add(mdname);
                    eventsMap.put(eventName, methodNames);
                } 
else {
                    methodNames.add(mdname);
                    eventsMap.put(eventName, methodNames);
                }
                comp.addEventListener(eventName, 
this);
                ((Component) o).addForward(srcevt, comp, eventName);
            }
        }
    }

看到上面的Object o = SpringUtil.getBean(srccompid);个人认为是从spring当中取bean来对比是否是Component。应该是从当前zul当中去取Component对象才对。
所以改这句为
Object o=comp.getFellow(srccompid);

再重新编译即可


posted on 2011-07-10 20:58 lancey 阅读(703) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


My Links

Blog Stats

常用链接

留言簿(2)

随笔档案

文章分类

文章档案

我的链接

搜索

最新评论

阅读排行榜

评论排行榜