Copy the code
The code is as follows:
/***//**
*Infinite recursion to obtain the json string of jsTree
*
*@paramparentId
*parent permission id
*@return
*/
privateStringgetJson(longparentId)
{
//Check out the top level
List
actions=actionManager.queryByParentId(parentId);
for(inti=0;i{
Actiona=actions.get(i);
//has child nodes
if(a.getIshaschild()==1)
{
str="{attributes:{id:" "a.getAnid()
""}, state: "open", data: "" a.getAnname()"",";
str="children:[";
//Find out its child nodes
Listlist=actionManager.queryByParentId(a.getAnid());
//Traverse its child nodes
for(intj=0;j{
Actionac=list.get(j);
//There are also child nodes (recursive call)
if(ac.getIshaschild()==1)
{
this.getJson(ac.getParentid());
}
else
{
str= "{attributes:{id:""ac.getAnid()
""},state:"open",data: ""ac.getAnname()
""""}";
if(j{
str=",";
}
}
}
str= "]";
str="}";
if(i{
str=","; }where Action is an entity such as menu class or permission class. Rendering: