在jsf中,我可以将一个sessionscope bean注入actionlistener吗?

时间:2011-06-26 11:33:26

标签: jsf javabeans actionlistener inject

在jsf中,我想将一个sessionscope bean注入一个actionlistener实现。可以吗?

2 个答案:

答案 0 :(得分:2)

像这样:

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

答案 1 :(得分:0)

通过这个..

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

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