我有以下代码XHTML:
<body>
<ui:composition template="/WEB-INF/inc/template.xhtml">
<ui:define name="pagename">
Home Page
</ui:define>
<ui:define name="content">
#{homeBean.message}
<p/><br/>
</ui:define>
</ui:composition>
</body>
,我有以下bean init():
@PostConstruct
public void init() {
message= "place holder for now";
LOG.info("we are in HOME BEAN init()");
try {
LOG.info("before flash insert travelRequest : " + travelRequest);
LOG.info("Flash map before insert FacesContext.getCurrentInstance().getExternalContext().getFlash() : " + FacesContext.getCurrentInstance().getExternalContext().getFlash());
FacesContext.getCurrentInstance().getExternalContext().getFlash().put("TravelRequest", travelRequest);
LOG.info("Flash map after insert FacesContext.getCurrentInstance().getExternalContext().getFlash() : " + FacesContext.getCurrentInstance().getExternalContext().getFlash());
LOG.info("after flash get travelRequest : " + FacesContext.getCurrentInstance().getExternalContext().getFlash().get("TravelRequest"));
}
}
似乎我放入闪光灯中的对象已保存在闪光灯中,但是当我尝试将其拉出时,我得到一个空值。请注意,在这个小片段下方,我还有更多代码,但此代码片段是通过给我返回放置在Flash中的对象的null来打破的。
以下是日志输出:
INFO - we are in HOME BEAN init()
INFO - before flash insert travelRequest : dao.TravelRequest@578c90eb
INFO - Flash map before insert FacesContext.getCurrentInstance().getExternalContext().getFlash() : []
INFO - Flash map after insert FacesContext.getCurrentInstance().getExternalContext().getFlash() : [ {TravelRequest, dao.TravelRequest@578c90eb}]
INFO - after flash get travelRequest : null
很显然,我的对象正在将其放入闪存,但无法将其取回。我只会得到空值。
发生了什么事?