1

2.2.1 からアップグレードした後、ダイアログ コンポーネント内のビュー スコープのバッキング Bean から一部のデータを表示できなくなりました。ダイアログがポップアップしますが、Bean からのデータは null に設定されます。

問題は、ボタンのリモート コマンドが、ダイアログ ウィジェットの show メソッドを再度呼び出す JavaScript を呼び出すことです。応答のレンダリング フェーズは、プロセスを通じて 2 回呼び出されます (ビューの復元フェーズは 1 回だけ呼び出されます)。1 回目は正しい値で、2 回目は null 値で。

ダイアログを直接表示するように onsucess 属性を変更すると、次のようになります。

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

ダイアログには値が正しく表示されます。代わりに onsuccess 属性の handleConfirm スクリプトを使用し、「return true;」をコメントアウトするとします。JavaScript から、ダイアログには値も表示されます。レンダリング フェーズが 1 回だけ呼び出されるようになりました。

これが追加のレンダリング フェーズをトリガーする理由についてのアイデアをいただければ幸いです。

JavaScriptを削除するのは少し気が進まない。これは元同僚のコードで、javascript のデータ パラメータが設定されているアプリケーションには何も見つかりません。その理由が私の代わりに理解が不足しているのか、それとも怪しいコードなのか、少しわかりません。アラート (data.text); 未定義を返します。

コード:

リモート コマンドを含む BuyProduct.xhtml:

<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>

javascript とダイアログを含む 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>

プライムフェイス 3.5 | モハラ 2.1.19 | ウェブロジック 10.3.3

4

1 に答える 1

0

returnこの場合、から値を削除する必要がありますonsuccess。false を返すと、デフォルトの DOM 更新プロセスがキャンセルされるため、これはあなたの場合の問題だと思います。

于 2013-03-11T10:52:35.550 に答える