Jsf Seam 2.2.2.a4j:mediaOutput之后显示的最终消息
我有这样一个xhtml:Jsf Seam 2.2.2.a4j:mediaOutput之后显示的最终消息,jsf,seam2,Jsf,Seam2,我有这样一个xhtml: <a4j:outputPanel id="displayGraph" layout="block" style="clear:both; margin-top: 0px; margin-left: 80px;margin-bottom: 20px;"> <a4j:mediaOutput element="img" cacheable="false" session="false" createContent="#{generateGr
<a4j:outputPanel id="displayGraph" layout="block" style="clear:both; margin-top: 0px; margin-left: 80px;margin-bottom: 20px;">
<a4j:mediaOutput element="img" cacheable="false" session="false" createContent="#{generateGraph.paint}" value="#{graph}" mimeType="image/png" standby="Loading" />
</a4j:outputPanel>
<a4j:outputPanel id="errorMessage" ajaxRendered="true">
<h:messages id="messages" styleClass="message" errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg"/>
</a4j:outputPanel>
public void paint(OutputStream os, Object data) {
try{
//some actions
} catch (IOException e) {
e.printStackTrace();
FacesMessages.instance().add(Severity.ERROR, "Sorry connection can not be achieved");
}
} else {
FacesMessages.instance().add(Severity.ERROR, "Sorry server does not exist");
}
}
现在,消息从未显示。谁能告诉我我做错了什么
提前感谢FacesMessages是一个对话范围的seam组件。假设您使用的是临时对话,则会发生以下情况:
#{conversation.id}
以及在paint()
方法中记录会话id来测试这一点
这个问题有两种解决方案。您可以启动一个长时间运行的对话,并将其添加到mediaOutput中。另一种解决方案是不使用FacesMessages,而是使用自定义页面范围的组件来保存消息
您还可以切换到RichFaces4,它为每个richfaces组件都包含一个“render”参数,确保在与初始mediaOutput AJAX请求相同的请求中发出重新渲染器