Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf Seam 2.2.2.a4j:mediaOutput之后显示的最终消息_Jsf_Seam2 - Fatal编程技术网

Jsf Seam 2.2.2.a4j:mediaOutput之后显示的最终消息

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

我有这样一个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="#{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组件。假设您使用的是临时对话,则会发生以下情况:

  • 对JSF页面的初始请求。临时对话#1已创建
  • 呈现JSF页面,会话#1被终止
  • 对mediaOutput的AJAX请求。创建临时对话2
  • 图像被渲染。FacesMessages对象绑定到对话#2
  • 返回图像。对话2被杀
  • a4j:outputPanel已渲染。创建临时对话#3
  • 对话#3中呈现了一条空脸消息
  • 您可以通过在a4j:outputPanels中包含
    #{conversation.id}
    以及在
    paint()
    方法中记录会话id来测试这一点

    这个问题有两种解决方案。您可以启动一个长时间运行的对话,并将其添加到mediaOutput中。另一种解决方案是不使用FacesMessages,而是使用自定义页面范围的组件来保存消息

    您还可以切换到RichFaces4,它为每个richfaces组件都包含一个“render”参数,确保在与初始mediaOutput AJAX请求相同的请求中发出重新渲染器