3

以下のコードで助けが必要です

                <h:commandButton  id="WhatifButtonID" value="#{demandBean.dmdReviewScreenLabelVO.whatIf}" style="width:60px; height:22px;"  actionListener="#{demandBean.whatif}"  onclick="window.open('DemandTargetList.xhtml','whatif','width=460,height=280,top=150,left=350,resizable=no,scrollbars=no')" >
                    <f:ajax execute="@this" ></f:ajax>
                </h:commandButton>

上記の場合、onclick 属性が最初に実行され、次に actionlistener 属性が実行されます。onclick をロードするページは actionListener から特定の値を取得する必要があるため、最初に actionListener 属性を実行し、次に onclick 関数を実行する必要がありました。同じことを達成する方法を教えてください。前もって感謝します。

4

2 に答える 2

4

<f:ajax>完了したらスクリプトをレンダリングさせてください。

<h:commandButton value="#{demandBean.dmdReviewScreenLabelVO.whatIf}" actionListener="#{demandBean.whatif}">
    <f:ajax execute="@this" render="popupScript" />
</h:commandButton>
<h:panelGroup id="popupScript">
    <h:outputScript rendered="#{demandBean.whatifPressed}">
        window.open('DemandTargetList.xhtml','whatif','width=460,height=280,top=150,left=350,resizable=no,scrollbars=no');
    </h:outputScript>
</h:panelGroup>

メソッドでに設定whatifPressedします。truewhatif()

于 2012-07-27T12:46:31.013 に答える
0

PrimeFaces は、<p:remoteCommand/>タグを使用してこれを支援する場合があります。次に、単純な古いボタンを使用して remoteCommand を呼び出し、window.open() を実行します。

<p:remoteCommand name="viewSomething" actionListener="#{someActionIWantToExecuteBeforeOpeningWindow}" update="@this" process="@this"/>
<button onclick="viewSomething(); window.open('http://somewhere.com', 'windowName', 'height=924,width=723');">Click me!</button>

ユニークなものを作成するjavascript関数を呼び出すと、アイテムのリストで使用できます。

于 2015-03-24T09:57:30.423 に答える