1

私はこのダイアログを持っています:

<p:dialog  header="Commande editée le #{acceuilUserController.selectedMajCommande.dateMaj} par l'#{acceuilUserController.selectedMajCommande.utilisateur.type} #{acceuilUserController.selectedMajCommande.utilisateur.nom} #{acceuilUserController.selectedMajCommande.utilisateur.prenom}" widgetVar="carDialog" resizable="false" id="carDlg"  
                     update="cars" showEffect="fade" hideEffect="explode" modal="true"> 

ユーザーがデータテーブルの下のボタンをクリックすると表示されます。

<p:column style="width:40px">                         
                        <p:commandButton  id="selectButton" action="#{acceuilUserController.refresh()}" update=":form:carDlg" oncomplete="carDialog.show()" icon="ui-icon-search" title="plus de détails">  
                            <f:setPropertyActionListener value="#{car}" target="#{acceuilUserController.selectedMajCommande}" />  
                        </p:commandButton>                       
                    </p:column> 

ユーザーがダイアログを閉じると、以下のメソッドが実行されます。

public String refresh(){
    this.selectedMajCommande.setLu(true);
    System.out.println("je suis la alors : "+this.selectedMajCommande.isLu());
    hch.updateCommandeMaj(selectedMajCommande);
    return "acceuil";
}

データをデータテーブルに更新することができます。次のようなダイアログのボタンでこれを作成することに成功しました:

 <p:commandButton id="confirm" value="fermer" update="cars" oncomplete="carDialog.hide()"
                                     action="#{acceuilUserController.refresh()}" />

しかし、ボックス内のこのボタンを必要とせずに、ダイアログを閉じるときにのみこれを行いたい

更新したいデータテーブルは次のとおりです。

<p:dataTable id="cars" var="car" value="#{acceuilUserController.lc_maj}"  tableStyle="width:auto" rowStyleClass="#{(car.lu == false) ? 'red' : null}" >  

                    <p:column headerText="Commande N° : " style="width:100px">  
                        <h:outputText value="#{car.commande.id}" />  
                    </p:column>  

                    <p:column headerText="Date de mise à jour : " style="width:100px">  
                        <h:outputText value="#{car.dateMaj}" />  
                    </p:column> 

                    <p:column headerText="Decision : " style="width:100px">  
                        <h:outputText value="#{car.decison}" />  
                    </p:column> 

                    <p:column headerText="Etat : " style="width:100px">  
                        <h:outputText value="#{car.etat}" />  
                    </p:column> 

                    <p:column style="width:40px">                         
                        <p:commandButton  id="selectButton" action="#{acceuilUserController.refresh()}" update=":form:carDlg" oncomplete="carDialog.show()" icon="ui-icon-search" title="plus de détails">  
                            <f:setPropertyActionListener value="#{car}" target="#{acceuilUserController.selectedMajCommande}" />  
                        </p:commandButton>                       
                    </p:column> 

                </p:dataTable>        

どうすればこれを達成できますか、事前に感謝します

4

2 に答える 2

0

これは、選択したコンポーネントを部分的に処理および更新するようにすでに構成されている PrimeFaces commandButton コンポーネントのクリック イベントを呼び出すような方法でクリック イベントをバインドする jQuery を使用して行うことができます。このスクリプトを、すべてのダイアログの外側に配置した複合コンポーネントに配置することで、同様のことを行いましたが、もちろん、これを行う方法はたくさんあります。

jQuery(document).ready(function() {
    // Searching for naming container that contains my dialog...
    var dashboardPanel = jQuery('*[id*=#{cc.attrs.id}]');
    // Find the dialog closer button by its unique class
    var closerButton = dashboardPanel.children().find('.ui-dialog-titlebar-close');
    closerButtons.bind('click', function(event) {
        // Use set timeout to delay the event if you want to see close animation effect
        setTimeout(function() { //Some logic to find the button client id
            var menuItemId = 'view#{cc.attrs.id}'.replace('Panel', '');
            jQuery('#' + menuItemId).click();
        }, 400);
    });
});

もちろん、動的 ID を持つ commandButton がない場合、または繰り返しコンテナー内にない場合は、Javascript で直接参照する方がはるかに簡単widgetVarです。

commandButtonWidget.jq.click();
于 2012-08-23T11:56:38.337 に答える
0

RequestContext次のように更新する必要があります。

public void update() {
   RequestContext requestContext = RequestContext.getCurrentInstance();
   requestContext.update("form:cars");
}
于 2013-10-26T14:07:19.630 に答える