2013-03-22 44 views
0

我正在使用JSF2和Richfaces 4的Java EE应用程序。我们决定使用模式窗口进行一些交互,并且我们选择了带h:form的Jquery UI对话框,因为我们已经在这个项目中使用了Jquery UI。jQuery UI对话框只能使用一次;第二次打开会导致ViewExpiredException在提交时

对话框打开正确,并提交表单,使用h:commandButton和a4j:ajax进行提交。 h:commandButton保持隐藏状态,并由对话框按钮触发。

一切看起来都很完美,但对话框/窗体只是一次。如果我关闭和打开对话框无需刷新页面我收到消息提交表单时:

javax.faces.application.ViewExpiredException: viewId:/frontend/inicial.xhtml - /frontend/inicial.xhtml无法恢复对话的

的JSF/HTML:

<h:panelGroup id="dialog-nova-intercorrencia" styleClass="ui-dialog-content ui-widget-content"> 
    <h:form id="frm-dialog-nova-intercor" prependId="false">   
     <table> 
      <tr> 
       <td>Paciente</td> 
       <td> 
        <h:selectOneMenu id="sel-intern-intercor" value="#{intercorrenciaController.novaIntercorrencia.internacao.internacaoID}" styleClass="ui-widget-content ui-corner-all"> 
         <f:selectItems value="#{internacaoController.listInternacoesSelectItem}" /> 
        </h:selectOneMenu> 
       </td> 
      </tr> 
      <tr> 
       <td>Impacto</td> 
       <td> 
        <h:selectOneMenu id="sel-impacto" value="#{intercorrenciaController.novaIntercorrencia.impacto.impactoID}" styleClass="ui-widget-content ui-corner-all"> 
         <f:selectItems value="#{intercorrenciaController.listaImpactosSelectItem}" /> 
        </h:selectOneMenu>       
       </td> 
      </tr> 
      <tr> 
       <td> 
        Data e Hora 
       </td> 
       <td> 
        <h:inputText value="#{intercorrenciaController.dataIntercorrencia}" styleClass="ui-widget-content ui-corner-all" style="width: 130px" /> 
        &#160; 
        <h:inputText value="#{intercorrenciaController.horaIntercorrencia}" styleClass="ui-widget-content ui-corner-all" style="width: 70px" /> 
       </td> 
      </tr> 
      <tr> 
       <td>Resumo</td> 
       <td><h:inputText value="#{intercorrenciaController.novaIntercorrencia.resumo}" size="25" styleClass="ui-widget-content ui-corner-all" /></td> 
      </tr> 
      <tr> 
       <td colspan="2"> 
        Comentarios 
        <br /> 
        <h:inputTextarea cols="30" rows="3" value="#{intercorrenciaController.novaIntercorrencia.descricao}" /> 
       </td> 
      </tr>     
     </table> 
     <h:commandButton id="btt-add-nova-intercor" action="#{intercorrenciaController.cadastrarIntercorrencia}" style="display:none"> 
      <a4j:ajax execute="@form" render="@form frm-dialog-nova-intercor panel-lista-intercorrencias" /> 
     </h:commandButton> 
    </h:form> 
</h:panelGroup> 

的JS创建jQuery用户界面对话框:

$("#dialog-nova-intercorrencia").dialog({ 
     position: { 
      my: "top top", 
      at: "top top", 
      of: window 
     }, 
     autoOpen: false, 
     height: 350, 
     width: 400, 
     draggable: false, 
     resizable: false, 
     modal: true, 
     buttons: { 
      "Cadastrar": function() { 
       $("#btt-add-nova-intercor").trigger("click"); 
      }, 
      "Cancelar": function() { 
       $(this).dialog("close"); 
       $(this).find("input").val(""); 
       $(this).find("textarea").val(""); 
       $(this).find("select").val(0);         
      } 
     }, 
     close: function() { 
      $(this).find("input").val(""); 
      $(this).find("textarea").val(""); 
      $(this).find("select").val(0); 
     } 
    }); 

有没有人知道我可以在dialong中只执行一次窗体的原因,并在第二次收到消息“查看无法恢复”?

+0

你为什么不使用RichFaces自己的['<丰富:popupPanel>'](http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=popup&skin=blueSky)? – BalusC 2013-03-22 20:27:54

+0

早些时候,这个项目使用了JSF 1.2和richfaces 3,这次我判断Richface的模式窗口没有我需要的所有功能,我不记得确切的原因。 – alberjoe 2013-03-22 20:37:47

+0

@BalusC 感谢您的意见和建议。 我认为文字并不完全可以理解。问题出现在第二次提交中,而不是第二次提交。打开确定,一次,两次,三次,但在第一次提交后,我收到错误消息。 – alberjoe 2013-03-22 21:33:54

回答

0

的问题是,我使用关闭对话框之前清除等领域的JS:

$(this).find("input").val(""); 

它是设置输入隐藏javax.faces.ViewState与空的形式。

<input type="hidden" name="javax.faces.ViewState" value="" />