Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 保存拖放位置面_Java_Jsf_Primefaces - Fatal编程技术网

Java 保存拖放位置面

Java 保存拖放位置面,java,jsf,primefaces,Java,Jsf,Primefaces,你好。这里有一个使用primefaces的拖放实现。这是给拖鞋的 <p:dataGrid id="availableComputers" value="#{coltsysLab.computer}" var="computer" columns="3" emptyMessage="No Computers Added Yet"> <p:column> <p:graphicImage id="computer" value="http://loca

你好。这里有一个使用primefaces的拖放实现。这是给拖鞋的

<p:dataGrid id="availableComputers" value="#{coltsysLab.computer}" var="computer" columns="3" emptyMessage="No Computers Added Yet">   
<p:column>  

    <p:graphicImage id="computer" value="http://localhost:8080/COLTSysResources/resources/images/#{computer.pic}" styleClass="computerImage" rendered="#{computer.status=='AVAILABLE'}"/>  

    <p:draggable for="computer" revert="true" scope="#{computer.status}" stack=".computerImage"/>

    <p:contextMenu for="computer">
        <p:menuitem value="Add Information" icon="ui-icon-plusthick" onclick="addInfoDlg.show();" action="#{coltsysLab.passComputerId(computer)}"/>
        <p:menuitem process="@this" value="Computer Information" icon="ui-icon-search" oncomplete="viewInfoDlg.show()" action="#{coltsysLab.passComputerId(computer)}"/>
    </p:contextMenu>

</p:column> 

当我使用浏览器的inspect元素时,我可以看到它的样式,如何才能获得值?

页面元素的位置由
style
属性表示。因此,在您的情况下,您只需要获取被删除组件的当前值。为此,您需要通过其clientId在视图中检索组件。不幸的是,JSF并没有提供一种简单的方法来获取这些信息(但是通过它的
id
来获取组件是非常容易的);我只知道暴力手段:

String dropId = dde.getDropId();  //get the currently dropped component
UIComponent theContainer =  FacesContext.getCurrentInstance().getViewRoot().findComponent("slots"); //you need a reference to the drop container
List<UIComponent> childComponents =  theContainer.getChildren(); //all dropped components are children of the datagrid

for(UIComponent child: childComponents){
   if(dropId.equals(child.getClientId()));{
      GraphicImage gImage = (GraphicImage) theComponent;
      String currentPosition = gImage.getStyle();
   }
}
String dropId=dde.getDropId()//获取当前删除的组件
UIComponent theContainer=FacesContext.getCurrentInstance().getViewRoot().findComponent(“插槽”)//您需要对放置容器的引用
List childComponents=container.getChildren()//所有丢弃的组件都是datagrid的子级
用于(UIComponent子组件:子组件){
if(dropId.equals(child.getClientId()){
GraphicImage gImage=(GraphicImage)组件;
字符串currentPosition=gImage.getStyle();
}
}

我猜组成部分是这个
ui组件组件=FacesContext.getCurrentInstance().getViewRoot().findComponent(“可用计算机:计算机”)但在getStyle@Francis-您可能应该在drop ajax listener的
进程
属性中包含
插槽
组件。如果检查正在查看的页面的元素源,您会注意到样式属性已更新,但它仅发生在客户端;JSF仍然需要被告知stylei added
process=“slots”
中的更改,但仍然为空
String dropId = event.getDropId();
UIComponent theContainer = FacesContext.getCurrentInstance().getViewRoot().findComponent(":organizeForm:slots"); 
UIComponent theComponent = FacesContext.getCurrentInstance().getViewRoot().findComponent(":organizeForm:availableComputers:computer");
List<UIComponent> childComponents = theContainer.getChildren();

    for (UIComponent child : childComponents) {

        System.out.println(child.getClientId());

        if (dropId.equals(child.getClientId())) {

            GraphicImage gImage = (GraphicImage) theComponent;
            String currentPosition = gImage.getStyle();
            System.out.println(currentPosition);
        }
    }
String dropId = dde.getDropId();  //get the currently dropped component
UIComponent theContainer =  FacesContext.getCurrentInstance().getViewRoot().findComponent("slots"); //you need a reference to the drop container
List<UIComponent> childComponents =  theContainer.getChildren(); //all dropped components are children of the datagrid

for(UIComponent child: childComponents){
   if(dropId.equals(child.getClientId()));{
      GraphicImage gImage = (GraphicImage) theComponent;
      String currentPosition = gImage.getStyle();
   }
}