简体   繁体   中英

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

In jsf, I want to inject a sessionscope 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());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM