In jsf, can i inject a sessionscope bean into an actionlistener?
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());
精彩评论