我是靠谱客的博主 多情毛衣,最近开发中收集的这篇文章主要介绍primefaces 2.0.3 新组件学习--treetable,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述



 由于以前项目采用richfaces的一个treetable存在性能问题,所以移植想找一个替代方案,primefaces的2.3日构建版本已经支持Treetable组件,测试了一下,性能还不错,

 

界面效果图:

 

treetable.xhtml

 <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">
Options
</f:facet>
<p:commandLink update="documentPanel" oncomplete="documentDialog.show()" title="View Detail">
<p:graphicImage value="/resources/images/search.png"/>
<f:setPropertyActionListener value="#{document}"
target="#{documentsController.selectedDocument}"/>
</p:commandLink>
</p:column>
</p:treeTable>
<p:dialog header="Document Detail" fixedCenter="true" effect="FADE" effectDuration="0.3"
widgetVar="documentDialog" modal="false">
<p:outputPanel id="documentPanel">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="name" value="Name: "/>
<h:outputText id="name" style="font-weight:bold"
value="#{documentsController.selectedDocument.name}"/>
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>

 

Java代码:

 

@ManagedBean()
@SessionScoped
public class DocumentsController {
//private static final Logger logger = Logger.getLogger(DocumentsController.class.getName());
private TreeNode root;
private TreeNode selectedDocument;
public DocumentsController() {
root = new DefaultTreeNode("root", null);
listFile("c:\temp",root);
}
public TreeNode getRoot() {
return root;
}
public void setRoot(TreeNode root) {
this.root = root;
}
public TreeNode getSelectedDocument() {
return selectedDocument;
}
public void setSelectedDocument(TreeNode selectedDocument) {
this.selectedDocument = selectedDocument;
}
public void onNodeSelect(NodeSelectEvent event) {
selectedDocument = event.getTreeNode();
//logger.info("Selected:" + selectedDocument.getData());
}
private long[] count = new long[]{0, 0};
private File file;
private long[] listFile(String path, TreeNode parent) {
file = new File(path);
File[] f = file.listFiles();
for (int i = 0; i < f.length; i++) {
if (f[i].isDirectory()) {
TreeNode documents = new DefaultTreeNode(file, parent);
this.listFile(f[i].toString(), documents);
} else {
TreeNode documents = new DefaultTreeNode(file, parent);
}
}
return count;
}
}

 

 

最后

以上就是多情毛衣为你收集整理的primefaces 2.0.3 新组件学习--treetable的全部内容,希望文章能够帮你解决primefaces 2.0.3 新组件学习--treetable所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部