Jsf PrimeFaces-从Showcase示例运行的树型问题
我将JSF2.0与PrimeFaces 3.0一起使用,并且可以使用TreeTable。发生以下错误:“/index.xhtml@69,62 value=“#{document.name}”:类“document”没有可读属性“name” 代码如下:Jsf PrimeFaces-从Showcase示例运行的树型问题,jsf,primefaces,treetable,Jsf,Primefaces,Treetable,我将JSF2.0与PrimeFaces 3.0一起使用,并且可以使用TreeTable。发生以下错误:“/index.xhtml@69,62 value=“#{document.name}”:类“document”没有可读属性“name” 代码如下: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<?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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Example</title>
</h:head>
<h:body>
<h:form>
<p:treeTable value="#{documentsController.root}" var="document">
<p:column>
<f:facet name="header">
Name
</f:facet>
<h:outputText value="#{document.name}" />
</p:column>
<p:column>
<f:facet name="header">
Size
</f:facet>
<h:outputText value="#{document.size}" />
</p:column>
<p:column>
<f:facet name="header">
Type
</f:facet>
<h:outputText value="#{document.type}" />
</p:column>
</p:treeTable>
</h:form>
</h:body>
</html>
豆子:
有什么想法吗?与showcase的方式完全相同:
解决方案如下所示。唯一的更改是,将bean从受保护访问更改为公共访问:
public class Document {
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 Document() {}
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;
}
}
谢谢大家 验证
公共类文档实现可序列化{
解决方案只是一个细节问题。文档类是用默认访问修饰符声明的。它必须是公共的。它现在正在工作。您需要将它作为答案重新发布。回答我自己的问题或用答案编辑它是更好的做法吗?当您说“重新发布”时,我没有想到。谢谢。@BalusC this is good try=DOr接受现有答案请注意,OP已经在对问题的评论中回答了自己的问题。
class Document {
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 Document() {}
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;
}
}
public class Document {
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 Document() {}
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;
}
}