- 爱易网页
-
Java教程
- myfaces的tree2组件生成树形菜单后,为什么子菜单的超链接会没反应?该如何解决
日期:2014-05-18 浏览次数:20705 次
myfaces的tree2组件生成树形菜单后,为什么子菜单的超链接会没反应?
部分代码如下:
public TreeNode getPermissionByUserid(String userid)//生成树的节点
{
TreeNode trees=new TreeNodeBase();
List modules=this.getModulenameByUserid(userid);
if(modules!=null)
{
for(int i=0;i <modules.size();i++)
{
String treename=(String)modules.get(i);
TreeNodeBase node = new TreeNodeBase( "a ",treename, "aaaa ",false);
//List treeChildren=tree.getChildren();
List sections=this.getSectionByModuleAndUserid(treename, userid);
if(sections!=null)
{
for(int j=0;j <sections.size();j++)
{
String sectionname=(String)sections.get(j);
TreeNodeBase treenode=new TreeNodeBase( "b ",sectionname,true);
treenode.setLeaf(true);
treenode.setIdentifier(sectionname);
node.getChildren().add(treenode);
//treeChildren.add(treenode);
}
}trees.getChildren().add(node) ;}
}
return trees;
}
public TreeNode getTrees()//调用上面的方法
{
FacesContext context=FacesContext.getCurrentInstance();
HttpSession session = (HttpSession)context.getExternalContext().getSession(true);
Userinfo user=(Userinfo)session.getAttribute( "user ");
return this.getPermissionByUserid(String.valueOf(user.getUserid()));
}
public TreeModel getTreeModel()//生成一个TreeModel供JSP调用
{
ApplicationContext ac=new
ClassPathXmlApplicationContext( "applicationContext.xml ");
UserService us=(UserService)ac.getBean( "userService ");
TreeNode tree=us.getTrees();
treeModel=new TreeModelBase(tree);
treeModel.setTreeState(treeState);
return treeModel;
}
jsp页面代码:
<t:tree2 id= "clientTree " value= "#{leftMenu.treeModel} " var= "node " varNodeToggler= "t "
showNav= "true "
showRootNode= "false " >
<f:facet name= "a ">
<h:panelGroup>
<h:outputText value= "#{node.description} " styleClass= "root " />
</h:panelGroup>
</f:facet>
<f:facet name= "b ">
<h:commandLink actionListener= "#{leftMenu.processAction} " value= "#{node.description} " id= "clickbutton " >