jsf - 在 Primefaces 中的不同布局单元之间拖放

标签 jsf jsf-2 primefaces drag-and-drop draggable

我在整页 Primefaces 布局中有 4 个布局单元。我在西部布局单元中有输出标签。我想将它拖放到中心布局单元。我想将输出标签拖放到此处的拖放区域是 tabView 中的一个面板。当我开始拖动 outputLabel 时,不要从西部布局单元出去。此外,当我将它拖到西部布局单元之外时,它就会消失。我该如何解决我的问题?我已经为此工作了 2 天,但我还没有成功。

这是我的代码:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html 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:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>

        </h:head>

        <h:body>
            <p:layout fullPage="true">

                <p:layoutUnit id="top" position="north" header="menu" size="100">
                </p:layoutUnit>

                <p:layoutUnit id="bottom" position="south" header="properties" size="100">
                </p:layoutUnit>

                <p:layoutUnit id="left" position="west" header="toolbox" size="200" style="overflow: visible" >
                    <p:outputLabel id="out1" value="outputlable"/>
                    <p:draggable for="out1" helper="clone"/>
                </p:layoutUnit>

                <p:layoutUnit id="middle" position="center" header="sayfa 1" >
                    <p:tabView>
                        <p:tab id="drop_page_1" title="Page 1">
                            <p:panel rendered="#{empty myBean.components}">
                                Please drag any component to here.
                            </p:panel>
                            <p:panel id="tab_panel" rendered="#{not empty myBean.components}">

                            </p:panel>
                        </p:tab>
                        <p:droppable id="drop_page_1" for="page_1"  >
                            <p:ajax listener="#{myBean.f_onCompDrop}" />
                        </p:droppable>
                    </p:tabView>
                </p:layoutUnit>
                <p:droppable for="middle" >
                    <p:ajax listener="#{myBean.f_onCompDrop}" />
                </p:droppable>
            </p:layout>

        </h:body>
    </f:view>
</html>

这是我的 bean :
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.event.DragDropEvent;
import java.util.List;
import javax.faces.component.UIComponent;


@ManagedBean(name="myBean")
@SessionScoped
public class NewJSFManagedBean {

    private List<UIComponent> components;
    public NewJSFManagedBean() {
    }
    public void f_onCompDrop(DragDropEvent ddEvent) {  
        UIComponent comp = ddEvent.getComponent().findComponent(ddEvent.getDragId());
        components.add(comp);  
    }

    public List<UIComponent> getComponents() {
        return components;
    }

    public void setComponents(List<UIComponent> components) {
        this.components = components;
    }  
}

最佳答案

我在 2 个布局单元之间拖动项目时遇到了同样的问题。我通过css完全解决了它。

我通过将“溢出”属性更改为“可见”来更改要拖出的容器。

我做的第二件事是将我想要拖入和放下的容器的“z-index”属性更改为负值。那为我修好了。

关于jsf - 在 Primefaces 中的不同布局单元之间拖放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20348499/

相关文章:

jsf - JSF/Liferay 6.2 多次包含 Javascript 文件

java - 从 Netbeans 中的现有实体生成表

view - JSF 2.0 隐式导航,不同的 View

ajax - 在 ajax 表单提交后保留 bean 属性

eclipse - 为什么 JSF 属性文件在 Eclipse 中不接受非 ASCII 字符?

jsf - java.lang.IllegalStateException : Could not find backup for factory javax. 面.application.ApplicationFactory

java - 当变量声明为 Long 时,Primefaces 选定的行为空

jsf - Primefaces fileUploadListener 不起作用

java - Primefaces DialogFramework Growl 和 showMessageInDialog 不工作

java - 为什么添加数据后无法刷新数据表?