當我嘗試使用可滾動的TreeTable(但它不會發生使用不可滾動的TreeTable)組件時,出現這個奇怪的錯誤。
組件根本不折疊或展開的點擊,如果我添加
style="margin-top:0" scrollable="true" scrollHeight="150"
到p:treetable中的組成部分。
如果我刪除它,它就像一個魅力。
試圖與兩個primefaces 4和5社區。
在tomcat 7上運行,使用mojarra 2.2.0。 (由蝕加入)的Oracle的Java 7.
試圖在兩個火狐30.0運行,鉻35和IE 11.
看起來像一些棄用JQuery的方法,但爲什麼primefaces 4和5將分發他們的單罐用錯誤的JQuery?
聽起來像我在這裏失去了一些東西。我應該怎麼做才能解決這個問題?
我已經使用Eclipse開普勒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());
}
}
方面
使用jQuery遷移插件.. –
加入jQuery的遷移-1.2.1.min.js到web內容\資源\ js和[H:outputScript名稱=「jquery的-migrate-1.2.1.min.js「library =」js「target =」head「]做的伎倆,謝謝! Primefaces在默認情況下不會分發這個js庫嗎? (隨時添加您的答案,所以我可以接受它並給你點) – Leo