开发者

In jsf, can i inject a sessionscope bean into an actionlistener?

开发者 https://www.devze.com 2023-03-15 16:49 出处:网络
In jsf, I want to inject a sessionsc开发者_如何学运维ope bean into an actionlistener implementation. Can it be done?Like this:

In jsf, I want to inject a sessionsc开发者_如何学运维ope bean into an actionlistener implementation. Can it be done?


Like this:

YourBean testBean = (YourBean)FacesContext.getCurrentInstance().getExternalContext()
               .getSessionMap().get( "yourBean");


go through this..

http://www.oio.de/public/java/jsf-best-practices-javaserver-faces-session-tips.htm

or

    ELContext elContext = context.getELContext();
    context.getApplication().getExpressionFactory()
       .createValueExpression(elContext,"#{sessionScope.sessionValue}", String.class)
       .setValue(elContext, this.getSessionValue());
0

精彩评论

暂无评论...
验证码 换一张
取 消