【问题标题】:Drag and drop richfaces problem拖放richfaces问题
【发布时间】:2010-12-13 12:41:44
【问题描述】:

这段代码给我带来了问题(richfaces 3.3.2.GA):

<rich:dragIndicator id="indicator"> </rich:dragIndicator>


                     <h:dataTable id="myData" value="#{resultArray}" var="data" >
                         <h:column>
                             <a4j:outputPanel>

                                <rich:dragSupport id="myDrag" dragIndicator="indicator" dragType="sug" dragValue="#{data}" >
                                    <rich:dndParam name="name" value="#{data.name}" >
                                        </rich:dndParam>                              
                                </rich:dragSupport>
                                <h:outputText value="#{data.name}"></h:outputText>



                            </a4j:outputPanel>
                         </h:column>
                     </h:dataTable>

        <rich:panel id="myPanel">
            <f:facet name="header">Drop Zone</f:facet>
                <rich:dropSupport id="dropZone" acceptedTypes="sug" dropListener="#{dropSuggestion}" reRender="box"/>
            </rich:panel>             


        <rich:dataTable  id="box" value="#{nameList}" var="cap2">
            <f:facet name="caption">Concepts chosen</f:facet>
                <h:column>
                    <h:outputText value="#{cap2.name}"/>
                </h:column>
        </rich:dataTable>

调用的动作:

public void dropSuggestion(DropEvent event)


             System.out.println("OntologyActions.dropSuggestions");
            FacesContext context = FacesContext.getCurrentInstance();


            OntologyActions dropItem = new OntologyActions();
            String dropItemString=event.getDragValue().toString();

           //Get request items
            dropItem= (OntologyActions) event.getDragValue();

           //Locate the position of the dropped element
           int index = dropItem.resultArray.indexOf(dropItemString);

           System.out.println("String: " + dropItemString + " DropItem: " + dropItem.resultArray.get(index).name + " Index: " + index);

           //Add the element to the selected array
               selectedSuggestionsArray.add(dropItem.resultArray.get(index));
            nameList.add(dropItemString);

           //resultArray.remove(dropItem);
     }

问题是,当我将元素放入放置区域时,不会发生任何操作,但我确信它可以看到这个放置区域,因为我看到绿色或红色,具体取决于接受的类型。

但是这个概念并没有从容器中移除,也没有添加到放置区。

当我到达此页面时,我收到此错误:

drop: 元素 [form1:j_id640:_form:myPanel] ID 是 在 DOM 树中找不到。

可能元素没有客户端 ID 或 客户 ID 尚未写入。 DnD 的 禁用。请检查!

在 JSF 控制台中(但只是第一次尝试),使用 firebug 进行调试:

找不到节点”代码:“8

有人熟悉吗?

提前致谢

【问题讨论】:

    标签: java drag-and-drop richfaces


    【解决方案1】:

    我认为您错误地定义了dropListener 方法。应该是dropListener="#{beanName.dropSuggestion}",不仅仅是我认为的方法名。这可以解释为什么没有执行任何操作。我不确定您遇到的其他错误。

    【讨论】:

    • Ther 问题与 a4j: form 及其不兼容有关。
    • @BlancaHdez 你有没有解决方案,即使我也面临同样的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-09
    • 1970-01-01
    • 2011-06-27
    • 2023-04-10
    • 2015-08-27
    相关资源
    最近更新 更多