public void onNodeSelect(final NodeSelectEvent event) { // Recursive search for selected node. this.updateNodeForSelected(this.studentRootNode, event.getTreeNode()); if (event.getTreeNode() != null && event.getTreeNode() instanceof StudentAcademicYearTreeNode) { StudentAcademicYearTreeNode treeNode = (StudentAcademicYearTreeNode) event.getTreeNode(); if (treeNode.getAcademicYear() != null) { // AcademicYear academicYear = treeNode.getAcademicYear(); // This code will be remove in future because this functionality // will be moved as dropdown. // this.studentBean.setStudentAcademicYear(academicYear); this.studentBean.setActiveTabIndex(0); this.studentBean.setViewOrNewAction(true); this.viewContentHandlerBean.setCurrentViewContent(ViewContentConstant.BRANCH_STUDENTS); } } else { this.viewContentHandlerBean.setCurrentViewContent(ViewContentConstant.BRANCH_STUDENTS); this.studentBean.setActiveTabIndex(0); this.studentBean.setViewOrNewAction(true); } }
public void loadStudentTree() { if (this.isLoadStudentTreeFlag()) { if (this.studentBean.getStudent() != null && this.studentBean.getStudent().getId() != null) { Student student = this.studentBean.getStudent(); // Some sorting login need to implemented. this.studentRootNode = new DefaultTreeNode("Root", null); this.studentRootNode.setExpanded(Boolean.TRUE); // Tree for class name node. this.studentNameNode = new DefaultTreeNode(student.getDisplayName(), this.studentRootNode); this.studentNameNode.setSelected(true); this.studentNameNode.setExpanded(true); TreeNode studentAcademicYearsTreeNode = new DefaultTreeNode("Academic years", this.studentNameNode); studentAcademicYearsTreeNode.setExpanded(true); studentAcademicYearsTreeNode.setSelectable(false); Collection<StudentAcademicYear> studentAcademicYears = this.serviceAcademicYearService.findStudentAcademicYearsByStudentId(student.getId()); for (StudentAcademicYear studentAcademicYear : studentAcademicYears) { StudentAcademicYearTreeNode studentAcademicYearTreeNode = new StudentAcademicYearTreeNode( studentAcademicYear.getAcademicYear().getDisplayLabel(), studentAcademicYear.getAcademicYear(), studentAcademicYearsTreeNode); studentAcademicYearTreeNode.setSelectable(true); } this.setLoadStudentTreeFlag(false); } } }