package org.brain.bean;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.brain.dbo.DBOperate;
import org.brain.pojos.Treemenu;
import org.brain.pojos.User;
import org.brain.tool.ToolBean;
@ManagedBean(name="treeMenuList")
@RequestScoped
public class TreeMenuList {
static int id;
String name;
Treemenu treeMenu = new Treemenu();
User user;
String nodeId;
boolean flag;
public TreeMenuList() {
// TODO Auto-generated constructor stub
user = ToolBean.getUserSession();
String requestId = ToolBean.getRequestParameter("id");
if(requestId!=null)
{
nodeId = requestId;
treeMenu = DBOperate.getTreeMenu(Integer.parseInt(nodeId));
name = treeMenu.getNodename();
}
}
public String reNameTree()
{
treeMenu = DBOperate.getTreeMenu(Integer.parseInt(nodeId));
treeMenu.setNodename(name);
flag = DBOperate.update(treeMenu);
return "renameTreeResult";
}
//删除菜单项里的父节点
public boolean delFatherNode()
{
System.out.println("delFatherNode start--------");
Treemenu treeMenu = DBOperate.getTreeMenu(Integer.parseInt(nodeId));
flag = DBOperate.delChildNode(treeMenu);
System.out.println("delFatherNode end--------");
return flag;
}
//删除菜单项里的子节点
public boolean delChildNode()
{
System.out.println("delChildNode start--------");
Treemenu treeMenu = DBOperate.getTreeMenu(Integer.parseInt(nodeId));
flag = DBOperate.delChildNode(treeMenu);
System.out.println("delChildNode end--------");
return flag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Treemenu getTreeMenu() {
return treeMenu;
}
public void setTreeMenu(Treemenu treeMenu) {
this.treeMenu = treeMenu;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public boolean getFlag() {
return flag;
}
public void setFlag(boolean flag) {
this.flag = flag;
}
}