2013-03-22 42 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="" />