嗨,我在设置组织图primeFaces 中的值时遇到问题。
我想向员工展示报告,所有事情都运转良好,但是我所面临的问题是,根据孩子的数量,父节点在重复。
所以请建议我任何最佳的处理方法。
以下是模型:
public TreeMap<String, String> getALLEmployees(OrganigramView ob) {
ConnectionHandler conHandler = ConnectionHandler.getConnectionHandler();
Connection con = conHandler.getConnection();
Statement stmt = null;
ArrayList<OrganigramView> list = new ArrayList();
OrganigramView obs;
TreeMap<String, String> tm = new TreeMap<String, String>();
try {
stmt = con.createStatement();
String selectQry = "select emp.* ,emp.Name as reportingName,ejd.`REPORTING_BOSS_ID`,emp2.`NAME` as reportToBy, emp.`EMPLOYEE_ID` as empID\n"
+ "from employee emp \n"
+ "JOIN employee_job_detail ejd ON ejd.`EMPLOYEE_ID` = emp.`EMPLOYEE_ID`\n"
+ "JOIN employee emp2 ON emp2.`EMPLOYEE_ID` = ejd.`REPORTING_BOSS_ID` \n"
+ " WHERE emp.COMPANY_ID = 4 and emp.`PROFILE_STATUS` = 1 ";
System.out.println("selectQry : " + selectQry);
ResultSet rs = stmt.executeQuery(selectQry);
while (rs.next()) {
tm.put( rs.getString("Name"),rs.getString("reportToBy") );
System.out.println(tm.size());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (stmt != null) {
stmt.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
conHandler.freeConnection(con);
}
return tm;
}
这是Bean:
protected OrganigramNode addDivision(OrganigramNode parent, String name, String... employees) {
OrganigramNode divisionNode = new DefaultOrganigramNode("division", name, parent);
divisionNode.setDroppable(true);
divisionNode.setDraggable(true);
divisionNode.setSelectable(true);
if (employees != null) {
for (String employee : employees) {
OrganigramNode employeeNode = new DefaultOrganigramNode("employee", employee, divisionNode);
employeeNode.setDraggable(true);
employeeNode.setSelectable(true);
}
}
return divisionNode;
}
这是XHTML
<p:organigram id="organigram"
widgetVar="organigram"
value="#{organigramView.rootNode}"
var="node"
>
<p:ajax event="dragdrop" process="@this" update="@form:growl" listener="#{organigramView.nodeDragDropListener}" />
<p:ajax event="select" process="@this" update="@form:growl" listener="#{organigramView.nodeSelectListener}" />
<p:ajax event="contextmenu" process="@this" />
<p:ajax event="collapse" process="@this" update="@form:growl" listener="#{organigramView.nodeCollapseListener}" />
<p:ajax event="expand" process="@this" update="@form:growl" listener="#{organigramView.nodeExpandListener}" />
<p:organigramNode>
<h:outputText value="#{node.data}" />
</p:organigramNode>
<p:organigramNode type="root"
style="border-radius: 10px;">
<h:outputText value="#{node.data}" />
</p:organigramNode>
<p:organigramNode type="division"
styleClass="division"
icon="pi pi-briefcase"
iconPos="left">
<h:outputText value="#{node.data}" />
</p:organigramNode>
<p:organigramNode type="employee"
styleClass="employee"
icon="pi pi-user">
<h:outputText value="#{node.data}" />
</p:organigramNode>
</p:organigram>
再次,我要重复所有的事情,但根据子节点的数量,只有父节点在重复,但是我希望应该显示一个父节点和一个子节点。