当我尝试使用可滚动的TreeTable(但不会使用不可滚动的TreeTable)组件时,我收到了这个奇怪的错误。
如果我添加
,该组件在点击时不会折叠或展开 style="margin-top:0" scrollable="true" scrollHeight="150"
到p:treeTable组件。
如果我删除它,它就像一个魅力。
尝试了两个主要的第4和第5社区。 p>
使用mojarra 2.2.0在tomcat 7上运行。 (由eclipse添加),Oracle Java 7。
尝试在firefox 30.0,chrome 35和IE 11上运行。
看起来像是一些弃用的JQuery方法,但是为什么第4和第5个方面会用错误的JQuery分发它们的单个jar?
听起来我在这里遗漏了一些东西。我该怎么做才能解决这个问题?
我使用Eclipse Kepler RC1创建了一个动态Web项目,这里是配置信息(非常香草)
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>prime</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
faces.config
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
</faces-config>
的index.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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">
<h:head>
</h:head>
<h:body>
<h1>Hello World PrimeFaces</h1>
<h:form>
<p:treeTable value="#{tree.root}" var="document" style="margin-top:0" scrollable="true" scrollHeight="150">
<f:facet name="header">
Document Viewer
</f:facet>
<p:column headerText="Name">
<h:outputText value="#{document.name}" />
</p:column>
<p:column headerText="Size">
<h:outputText value="#{document.size}" />
</p:column>
<p:column headerText="Type">
<h:outputText value="#{document.type}" />
</p:column>
</p:treeTable>
</h:form>
</h:body>
</html>
托管bean
package prime;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;
@ManagedBean(name = "tree")
@ViewScoped
public class TreeBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private TreeNode root;
@PostConstruct
public void init() {
root = createDocuments();
// root.getChildren().get(0).setExpanded(true);
}
public TreeNode getRoot() {
return root;
}
public TreeNode createDocuments() {
TreeNode root = new DefaultTreeNode(new Document("Files", "-", "Folder"), null);
TreeNode documents = new DefaultTreeNode(new Document("Documents", "-", "Folder"), root);
for(int i=0;i<100;i++){
new DefaultTreeNode("document", new Document("doc"+i, "40 KB", "Document"), documents);
}
return root;
}
}
实体bean
package prime;
import java.io.Serializable;
public class Document implements Serializable, Comparable<Document> {
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
private String size;
private String type;
public Document(String name, String size, String type) {
this.name = name;
this.size = size;
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
//Eclipse Generated hashCode and equals
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((size == null) ? 0 : size.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Document other = (Document) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (size == null) {
if (other.size != null)
return false;
} else if (!size.equals(other.size))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
}
@Override
public String toString() {
return name;
}
public int compareTo(Document document) {
return this.getName().compareTo(document.getName());
}
}
面
答案 0 :(得分:1)
$。浏览器最近在jquery中被弃用了。要使用已弃用的函数,请使用jquery migrate plugin
该插件可恢复已弃用的功能和行为,以便更旧 代码仍然可以在jQuery 1.9及更高版本上正常运行。