Skip to content

Commit

Permalink
class to control the org chart PF extensions
Browse files Browse the repository at this point in the history
Signed-off-by: Andres LeonRangel <[email protected]>
  • Loading branch information
aleon1220 committed May 12, 2024
1 parent f35513c commit 00b4c72
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions src/main/java/bean/OrgchartController.java
Original file line number Diff line number Diff line change
@@ -1,2 +1,64 @@
package bean;public class OrgchartController {
}
package bean;

import java.io.Serializable;
import jakarta.inject.Named;
//https://jakarta.ee/specifications/platform/9/apidocs/jakarta/faces/bean/viewscoped
import jakarta.faces.view.ViewScoped;
import org.primefaces.extensions.component.orgchart.OrgChartNode;
import org.primefaces.extensions.component.orgchart.DefaultOrgChartNode;
import org.primefaces.extensions.event.OrgChartClickEvent;
import org.primefaces.extensions.event.OrgChartDropEvent;

@Named
@ViewScoped
public class OrgchartController implements Serializable {

private static final long serialVersionUID = 1648477595853984820L;

private OrgChartNode orgChartNode;

private String direction = "t2b";

public OrgchartController() {
super();
init();
}

public void init() {
orgChartNode = new DefaultOrgChartNode("id1", "Cohort March 2023", "2023-03-20");
orgChartNode.addChild(new DefaultOrgChartNode("id2", "Cloud Basics", "Content2"));
orgChartNode.addChild(new DefaultOrgChartNode("id3", "Programming Java", "Content3"));
orgChartNode.addChild(new DefaultOrgChartNode("id4", "Programming Python", "Content3"));
final OrgChartNode node = new DefaultOrgChartNode("id5", "Iac", "Infra as Code");
orgChartNode.addChild(node);
node.addChild(new DefaultOrgChartNode("id6", "pulumi", "with java programming language"));
node.addChild(new DefaultOrgChartNode("id7", "terraform", "HCL Hashicorp config language"));
}

public static void onClick(final OrgChartClickEvent event) {
System.out.println("clicked ID: " + event.getId());
System.out.println("hierarchy: " + event.getHierarchy().toString());
}

public static void onDropOver(final OrgChartDropEvent event) {
System.out.println("hierarchy: " + event.getHierarchy().toString());
System.out.println("dragged node id " + event.getDraggedNodeId());
System.out.println("dropped node id " + event.getDroppedZoneId());
}

public OrgChartNode getOrgChartNode() {
return orgChartNode;
}

public void setOrgChartNode(final OrgChartNode orgChartNode) {
this.orgChartNode = orgChartNode;
}

public String getDirection() {
return direction;
}

public void setDirection(final String direction) {
this.direction = direction;
}
}

0 comments on commit 00b4c72

Please sign in to comment.