`
kisaii
  • 浏览: 7279 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

在Composer或者ViewModel外获取Spring Bean

    博客分类:
  • zk
zk 
阅读更多
ZK在Composer或者ViewModel外,不会自动注解Spring bean,所以要手工获取.如下:

@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
public class AuthenticationInit implements Initiator {

    @WireVariable
    AuthenticationService authService;
    
    public void doInit(Page page, Map<String, Object> args) throws Exception {
        //wire service manually by calling Selectors API
        Selectors.wireVariables(page, this, Selectors.newVariableResolvers(getClass(), null));        
        UserCredential cre = authService.getUserCredential();
        if(cre==null || cre.isAnonymous()){
            Executions.sendRedirect("/chapter8/login.zul");
            return;
        }
    }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics