我已经尝试了几十个谷歌搜索中的每一个解决方案:getRequestMap、ElResolver、evaluateExpressionGet 等等。没有,绝对没有,工作。我null
每次都得到。以下是相关代码:
@ManagedBean(name="readerBean")
@ViewScoped
public class ReaderBean implements Serializable {...
在 PhaseListener 中:
public void beforePhase(PhaseEvent event) {
if (event.getPhaseId() == PhaseId.RESTORE_VIEW) {
ReaderBean r = null; //The Managed Bean
try {
FacesContext fctx = FacesContext.getCurrentInstance();
r=(ReaderBean) fctx.getExternalContext().getRequestMap().get("readerBean");
r=(ReaderBean) fctx.getELContext().getELResolver().getValue(fctx.getELContext(), null, "readerBean");
r=(ReaderBean) fctx.getApplication().getExpressionFactory().createValueExpression(fctx.getELContext(), "#{readerBean}", ReaderBean.class).getValue(fctx.getELContext());
r=(ReaderBean) fctx.getApplication().evaluateExpressionGet(fctx, "#{readerBean}", ReaderBean.class);
什么都没用!!!