0

ap:droppable コンポーネントに 2 つの ajax リスナーが必要です。

それは機能しますが、リスナーはそれぞれ 2 回呼び出されます。

<ui:repeat id="orderGroups" value="#{omsOrderActionBean.order.orderGroups}" var="group">
  <p:panel > 
   <p:fieldset id="selectedLineItems" style="margin-top:20px">
    <p:dataTable>
         ...
    </p:dataTable>
   </p:fieldset>
 </p:panel>
 <p:droppable for=":frmItem:tabViewSections:orderGroups:selectedLineItems"
  tolerance="touch" activeStyleClass="ui-state-highlight" datasource=":frmItem:tabViewSections:availableItems" onDrop="handleDrop">
    <p:ajax listener="#{omsOrderActionBean.setSelectedOrderGroup(group)}" immediate="true" />
    <p:ajax listener="#{omsOrderActionBean.onArticleDrop}" update=":frmItem:tabViewSections:outpOrderGroups :frmItem:tabViewSections:availableItems" />
 </p:droppable>
</ui:repeat>

その行動を避ける方法を知っていますか?または、引数を ajax イベントに渡す方法は?

4

2 に答える 2

0

同じイベントに対して 2 つの ajax リスナーを使用しないことを強くお勧めします。これにより、クライアント/サーバーのトラフィックが増加し、システムの速度が低下する複数の ajax リクエストが実行されます。代わりに、それらの 1 つだけを実行し、そこでロジック全体を実行してください。

<p:ajax listener="#{omsOrderActionBean.onDrop}" 
    update=":frmItem:tabViewSections:outpOrderGroups :frmItem:tabViewSections:availableItems" />

ドロップされたオブジェクトを取得するには、 showcaseで指定された署名に従う必要があります。

public void onDrop(DragDropEvent event) {  
    Group group = (Group) event.getData();  
}  
于 2013-10-04T09:19:48.210 に答える
0

私は自分の問題の解決策を見つけました。私は 1 つの ajax リスナーのみを使用します。このリスナーで、グループの位置を含む dropId を取得します。次に、それを整数に変換して、注文のリストから取得します。

// DropId is of the form: orderGroups:0:selectedLineItems
String[] dropSplit = ddEvent.getDropId().split(":");
// Get the second part to retrieve the correct orderGroup:
int orderGroupPosition = Integer.parseInt(dropSplit[2]);
orderGroups.get(orderGroupPosition);
于 2013-10-04T12:39:31.753 に答える