2012-04-16 3 views
1

두 개의 패널이 있습니다. 하나는 소스이고 다른 하나는 싱크입니다.Richface 4.2 DragandDrop가 작동하지 않습니다.

enter image description here

지금 내가

코드 PHP 패널에 소스에서 객체를 이동하려는 :

public class DragDropBean{ 
    private List<String> source; 
    private List<String> target; 
// ----------> NOW getter and setter of all three element 
    public DragDropBean() { 
     initList(); 
    } 

    private void initList() { 
     source = Lists.newArrayList(); 
     target = Lists.newArrayList(); 
     source.add("A"); 
     source.add("B"); 
     source.add("C"); 
     source.add("D"); 
    } 

    public void moveItem(String obj) { 
     source.remove(obj); 
     target.add(obj); 
    } 

코드 이벤트 콩에 대한

public class DragDropEventBean implements DropListener { 
    @ManagedProperty(value = "#{dragDropBean}") 
    private DragDropBean dragDropBean; 
// -----> NOW getter setter of dragDropBean 

    public void processDrop(DropEvent event) { 
     dragDropBean.moveItem((String) event.getDragValue()); 
    } 

XHTML 파일 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:rich="http://richfaces.org/rich"> 
    <f:view> 
    <h:head></h:head> 
    <h:outputStylesheet> 
     .panelc { width:25%; } 
     .valign { vertical-align:top; } 
     .dropTargetPanel { width: 90%; } 
     .footerClass { 
      text-align: center; 
      padding-top: 5px; 
     } 
     .rf-ind-drag{ 
      font-size:11px; 
      cursor:pointer; 
      width:100px; 
      border:1px solid gray; 
      padding:2px 
     } 
     .rf-ind-acpt{border:2px solid green} 
     .rf-ind-rejt{border:2px solid red} 
    </h:outputStylesheet> 
    <h:form id="form"> 
     <h:panelGrid columnClasses="panelc valign, valign, valign, valign" columns="4" width="100%"> 
      <rich:panel style="width:133px"> 
       <f:facet name="header"> 
        <h:outputText value="Source List" /> 
       </f:facet> 
       <h:dataTable 
        id="src" 
        columns="1" 
        value="#{dragDropBean.source}" 
        var="fm1" 
        footerClass="footerClass"> 
        <h:column> 
         <a4j:outputPanel layout="block" styleClass="rf-ind-drag"> 
          <rich:dragSource 
           type="PHP" 
           dragValue="#{fm1}" /> 
          <h:outputText value="#{fm1}"></h:outputText> 
         </a4j:outputPanel> 
        </h:column> 
       </h:dataTable> 
      </rich:panel> 

      <rich:panel> 
       <f:facet name="header"> 
        <h:outputText value="PHP Frameworks" /> 
       </f:facet> 
       <rich:dropTarget 
        acceptedTypes="PHP" 
        dropListener="#{dragDropEventBean.processDrop}" 
        render="phptable, src" /> 
       <h:dataTable 
        id="phptable" 
        columns="1" 
        value="#{dragDropBean.target}" 
        var="fm2"> 
        <h:column> 
         <h:outputText value="#{fm2}"></h:outputText> 
        </h:column> 
       </h:dataTable> 
      </rich:panel> 

     </h:panelGrid> 
    </h:form> 
    </f:view> 
</ui:composition> 

dragDropEventBean은 요청 범위이고 dragDropBean은 뷰 범위입니다.

패널 원본에서 PHP로 개체를 이동할 수 없습니다.

감사

+0

rich : dropTarget에 을 추가하려고했습니다. 하지만 여전히 작동하지 않습니다. – user811602

답변

0

봅니다 전체 DragAndDrop 예 here 또는 here를 얻을 수 있습니다.

이러한 링크는 사용중인 코드와 동일하지만 완료되었습니다. 나는 그것을 얻고 나를 위해 일한다. 어쩌면 중요한 코드를 없앨 수도 있습니다.

게다가 페이지에 <a4j:log/>을 삽입하여 디버그 정보를 표시하고 예외가 있는지 확인할 수 있습니다.

관련 문제