1

Richfaces4とJSF2でドラッグアンドドロップコンポーネントを使用しています。

アクション(最初のパネル)をターゲットパネルにドラッグアンドドロップすると、すべてが正常に機能します。しかし、オブジェクト(2番目のパネル)をターゲットパネルにドラッグアンドドロップしようとしたとき。次の例外が発生します。

例外

debug[16:27:48.572]: Server returned responseText: <?xml version='1.0' encoding='UTF-8'?> <partial-response><error><error-name>class java.lang.NullPointerException</error-name><error-message><![CDATA[]]></error-message></error></partial-response>
info [16:27:48.574]: Element error
<error><error-name>class java.lang.NullPointerException</error-name><error-message><![CDATA[]]></error-message></error>
debug[16:27:48.574]: richfaces.queue: ajax submit error
debug[16:27:48.575]: richfaces.queue: Nothing to submit
error[16:27:48.576]: Received 'error@serverError' event from <div id=dropForm:list:0:j_idt42 class=rf-ind-drag ui-draggable ...>
error[16:27:48.577]: [200] class java.lang.NullPointerException:

ソースパネル

<rich:panel id="Object">

    <h:dataTable value="#{dropBean.objects}" var="object">
        <h:column>
        <a4j:outputPanel layout="block">
             <rich:dragSource type="#{dropBean.objectType}" dragValue="#{object}" />
             <h:outputText value="#{object}"></h:outputText>
        </a4j:outputPanel>
        </h:column>
        </h:dataTable>
</rich:panel>

ターゲットパネル1

<h:panelGrid columns="4">
    <rich:panel styleClass="idPanel" >
    <rich:panel>
    <rich:dropTarget acceptedTypes="ACTION" dropListener="#{dropBean.processDrop}" render="editPanel" />
    <rich:tooltip value="Drop here an Action..." />
    <a4j:outputPanel>
    <h:outputText value="#{dropBean.currentLine.action}"></h:outputText>
        </a4j:outputPanel>
    </rich:panel>
    <ui:include src="#{dropBean.pageByAction}" />
    <a4j:commandButton styleClass="opButtons" value="Add Step" action="#{dropBean.saveLine}" render="editPanel" />
</h:panelGrid>

<ui:include src="#{dropBean.pageByAction}" />最初のターゲットパネルにドロップしたアクションに応じて、行は正しいページを取得します。

含まれているページ(ターゲットパネル2)の例を次に示します。

ターゲットパネル2

<h:panelGrid columns="3">
     <rich:panel styleClass="itemPanel" bodyClass="itemPanelBody">
     <rich:dropTarget acceptedTypes="OBJECT" dropListener="#{dropBean.processDrop}" render="@form" />
     <rich:tooltip value="Drop here an Object..." />
     <a4j:outputPanel>
     <h:outputText value="#{dropBean.currentLine.object}" />
     </a4j:outputPanel>
     </rich:panel>
</h:panelGrid>

を削除し<ui:include src="#{dropBean.pageByAction}" />てコードを直接挿入すると、ドロップ操作が正しく機能します。しかし、このように、パネルは動的ではありません。選択したアクションに応じてパネルを生成する必要があります。

私がすでに試したがうまくいかない他のこと:

  1. すべてのページをレンダリングしようとして、render = "@ form" "formName""@all"を挿入します。
  2. rich:listやrich:dataGridなどの他のコンポーネントのデータテーブルを変更します
  3. ドロップターゲットコンポーネントで即時使用します。

事前にThks、

4

1 に答える 1

0

ページを強制的に更新する問題を解決しました。

オブジェクトをターゲット パネルにドラッグ アンド ドロップすると、Backing Bean のメソッドが呼び出されます。

public void processDrop(DropEvent event) {

    //process event (not relevant code)

    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = context.getViewRoot().getViewId();
    ViewHandler handler = context.getApplication().getViewHandler();
    UIViewRoot root = handler.createView(context, viewId);
    root.setViewId(viewId);
    context.setViewRoot(root);
}

これが最善の解決策ではないと確信しており、より良い解決策を求めています。その間、私はそれにとどまります。

誰かがより良い解決策を持っている場合は、私に知らせてください。

于 2012-10-09T14:31:43.243 に答える