2013-03-08 98 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更新过程,所以我认为这是你的情况的问题。

相关问题