我正在尝试显示单个选择树视图,您应该在其中选择 Primefaces 3.3.1/JSF 2.0 新项目将进入哪个文件夹。到目前为止,我已经用文件夹和子文件夹填充了树:
但是,当我尝试选择一个文件夹时:什么也没有发生。我的.xhtml
页面如下所示:
<h:form id="createSiteForm">
<label>Under vilken mapp ska sidan ligga under: </label><br />
<p:tree id="treeSingle" value="#{siteBean.root}" var="node"
selectionMode="single"
selection="#{siteBean.selectedNode}" dynamic="true" cache="false">
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
</h:form>
我的managed bean
:
@ManagedBean(name = "siteBean")
@RequestScoped
public class SiteBean implements Serializable {
private TreeNode root;
private TreeNode selectedNode;
public SiteBean(){
this.loadTreeNodes();
}
@SuppressWarnings("rawtypes")
public void loadTreeNodes(){
try {
WebDB db = new WebDB();
List<Folder> folders = db.getRootFolders();
root = new DefaultTreeNode("Root", null);
boolean first = true;
db = null;
for (Iterator fi = folders.iterator(); fi.hasNext();){
Folder folder = (Folder) fi.next();
TreeNode node = new DefaultTreeNode(folder.getName(), root);
if(first){
node.setSelected(true);
selectedNode = node;
first = false;
}
this.findNodeChildren(folder.getId(), node);
}
} catch (DatabaseException e) {
e.printStackTrace();
}
}
@SuppressWarnings("rawtypes")
private void findNodeChildren(Long id, TreeNode parent){
try {
WebDB db = new WebDB();
List<Folder> fChildren = db.getFolderChildren(id);
db = null;
if(fChildren != null && fChildren.size() > 0){
for (Iterator fi = fChildren.iterator(); fi.hasNext();){
Folder folder = (Folder) fi.next();
TreeNode node = new DefaultTreeNode(folder.getName(), parent);
this.findNodeChildren(folder.getId(), node);
}
}
} catch (DatabaseException e) {
e.printStackTrace();
}
}
public TreeNode getRoot() {
return root;
}
public TreeNode getSelectedNode() {
return selectedNode;
}
public void setSelectedNode(TreeNode selectedNode) {
this.selectedNode = selectedNode;
}
}
我得到了这个奇怪的 jQuery 错误:Uncaught TypeError: Cannot call method 'remove' of null
在primefaces.js?ln=primefaces
. 我找不到有关此错误的任何信息:S