2013-03-08 90 views
1

從2.2.1升級後,我無法再顯示對話框組件中的視圖範圍支持bean的某些數據。彈出對話框,但來自該bean的數據設置爲空。升級到Primefaces 3.5後remotecommand onsuccess無法正常工作

問題似乎是按鈕的遙控命令調用一個JavaScript,它再次調用對話框小部件上的show方法。渲染響應階段被調用兩次直到進程(恢復視圖階段只調用一次)。第一次使用正確的值,第二次使用空值。

如果我改變onsucess屬性直接顯示在對話框:

<p:remoteCommand name="lazyload" onsuccess="confirmdialog.show();" 
update=":confirm" > 

對話框正確顯示的值。如果我使用onsuccess屬性中的handleConfirm腳本並註釋掉「return true;」從javascript的對話框中也顯示了值。渲染階段現在只調用一次。

任何想法爲什麼這可能會觸發一個額外的渲染階段將不勝感激。

我有點不情願刪除JavaScript。這是前同事的代碼,並且我無法在設置javascript數據參數的應用程序中找到任何內容。我有點不確定,原因是我的代表缺乏理解或腥的代碼。警報(data.text);返回undefined。

代碼:

BuyProduct.xhtml包含遠程命令:包含的JavaScript和對話

<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:fn="http://java.sun.com/jsp/jstl/functions" 
    xmlns:comp="http://java.sun.com/jsf/composite/components"> 


    <ui:include src="/confirmOrder.xhtml"/> 

    <h:form> 
     <p:commandButton disabled="#{productsearch.hasCP == false}" 
     onclick="if(canhide == false) {return false;} if(submitelement!=this||cansubmit==false) { cansubmit = false; submitelement=this; lazyload(); return false;} cansubmit = false; submitelement=null; canhide=false; loading.show(); return true;" 
      ajax="false" value="${msgs.order}" 
      actionListener="#{cp.PerformSearch}" 
      action="/services/cPReply.xhtml"> 
      <f:setPropertyActionListener value="#{confirmorder.targetGateway}" target="#{cp.gateway}" /> 
      <f:setPropertyActionListener value="#{productsearch.code}" target="#{cp.code}" /> 
      <f:setPropertyActionListener value="#{productsearch.registerId}" target="#{cp.registerId}" /> 
     </p:commandButton> 
     <p:remoteCommand name="lazyload" onsuccess="return handleConfirm(data);" update=":confirm" > 
       <f:setPropertyActionListener value="#{productsearch.cPGW.gateway_id}" target="#{confirmorder.gatewayId}" /> 
       <f:setPropertyActionListener value="CP" target="#{confirmorder.serviceName}" /> 

     </p:remoteCommand> 

confirmOrder.xhtml:

<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:c="http://java.sun.com/jsp/jstl/core" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"> 

    <script> 
     var cansubmit = false; 
     var submitelement = null; 

     function handleConfirm(data) 
     { 
      if(data.getElementsByTagName("error") != null &amp;&amp; data.getElementsByTagName("error")[0] != null) { 
       sessiontimeout.show(); 
       return false; 
      } 
      else { 

        confirmdialog.show(); 
      } 

      return true; 
     } 

    </script> 


    <p:dialog header="${msgs.buyProducts}" widgetVar="confirmdialog" id="confirmdialogiden" 
     modal="true" resizable="false" width="700" dynamic="true"> 
     <h:panelGrid id="confirm"> 
      <f:view beforePhase="#{confirmorder.beforePhase}" afterPhase="#{confirmorder.afterPhase}"> 
      <ui:debug hotkey="x"></ui:debug> 
      <h:panelGrid id="noProductSelected" rendered="#{confirmorder.size==false}"> 
       ${msgs.noProductSelected} 
       </h:panelGrid> 
      <h:panelGrid id="productSelected" columns="2" rules="cols" rendered="#{confirmorder.size}" > 
        <h:panelGrid width="400" id="productSelectedSub"> 

         <b>${msgs.products}</b> 

         <p:dataList value="#{confirmorder.products}" var="car"> 
       #{car.product_description}, #{car.price_nok} 
         </p:dataList> 

         <p:separator /> 
         <b>${msgs.amount} </b> 
         <h:outputText id="total" value="#{confirmorder.sum} " /> 
        </h:panelGrid> 

      </h:panelGrid> 
     </h:panelGrid> 
     </:dialog> 

Primefaces 3.5 | Mojarra 2.1.19 | Weblogic 10.3.3

+0

你想通過在這裏返回'true'或'false' fromsuccess方法來做什麼? – partlov 2013-03-08 13:43:32

+0

刪除退貨可解決問題。謝謝。 – Bjorg 2013-03-11 08:36:06

+0

我會添加一個答案。 – partlov 2013-03-11 10:51:11

回答

0

在這種情況下,您應該從onsuccess中刪除return值。返回false將取消默認的DOM更新過程,所以我認爲這是你的情況的問題。

相關問題