如何在Hierarchical上实现CRUD操作并将其显示为属性grid或treegrid?

时间:2016-01-21 10:48:01

标签: java hibernate jsp spring-mvc

有人可以指导我,如何插入像父母一样的分层数据 - >孩子 - >大孩子 - >等等..我需要在UI上将其显示为动态属性网格或树状网格。

   MyRootData
      MyChild1Data 
         MyGrandchild11Data
         MyGrandchild12Data
            MyGreatGrandchild121Data
         MyGrandchild13Data
      MyChild2Data
         MyGrandchild21Data
         MyGrandchild22Data
   MyRootData
      MyChild1Data 
         MyGrandchild11Data
         MyGrandchild12Data
            MyGreatGrandchild121Data
         MyGrandchild13Data
      MyChild2Data
         MyGrandchild21Data
         MyGrandchild22Data 

我在Spring mvc Hibernate中尝试这个,我有点打击,请帮助我。如果有任何使用完整示例/代码库请分享。

模式

@Entity
@Table(name ="Textual_Req")
public class TextualReq {

       @Id
       @GeneratedValue( generator = "increment" )
       @GenericGenerator( name = "increment", strategy = "increment" )
       @Column(name="ID")
       private int                    id;

       @ManyToOne
       @JoinColumn(name="parent")
       private TextualReq                parent;
       @OneToMany( mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER )
       @Column(name="children")
       private Set<TextualReq> children = new HashSet<TextualReq>();
       @Column(name="data")
       private String                  data;

和DAO是

@SuppressWarnings("unchecked")
    @Override
    public List<TextualReq> listTextualReq() {
        Session session = this.sessionFactory.getCurrentSession();
        List<TextualReq> textualReqList = session.createQuery("from TextualReq where parent is null").list();
        for(TextualReq root : textualReqList){
            logger.info("textualReqList ::"+root);
             root.display( "   " );
        }
        return textualReqList;
    }

控制器

@RequestMapping(value = "/textualReq", method = RequestMethod.GET)
    public String listRequestReq(Model model) {
        model.addAttribute("textualReq", new TextualReq());
        model.addAttribute("listtextualReq", this.textualReqService.listTextualReq());
        return "textualReq";
    }

0 个答案:

没有答案