skip to main content
Diagrammer > Programmer's documentation > Building Web applications > Developing JViews Diagrammer JavaScript Web applications > Creating nodes and links
 
Creating nodes and links
Describes how to create nodes and links in your JavaScript Web applications.
*Overview
*Provides an overview of the class used to create nodes and links.
*Client-side configuration
*Shows how to configure nodes and links on the client side of the JavaScript Web application.
*Server-side configuration
*Shows how to configure nodes and links on the server side of the JavaScript Web application.
Overview
The ability of interactively creating nodes and links in a JavaScript Web application is handled through the IlvMakeObjectInteractor class.
When the IlvMakeObjectInteractor class is set on the view and configured as a node creation interactor, it allows you to create nodes by clicking on their expected position on the view.
Alternatively, when the IlvMakeObjectInteractor class is configured as a link creation interactor, it allows you to create links by clicking the mouse on the origin node, dragging the mouse and then releasing it on top of the destination node.
NOTE Normally, the creation of nodes and links is expected only in multisession mode.
Client-side configuration
To be able to interactively create nodes and links on the client side, import the following scripts:
 
<script TYPE="text/javascript" src="script/IlvAbstractSelectionManager.js">
</script>
<script TYPE="text/javascript" src="script/framework/IlvSelectionManager.js">
</script>
<script TYPE="text/javascript" src="script/framework/IlvMakeObjectInteractor.js"></script>
The interactor can be instantiated, configured and set as follows:
 
var interactor = new IlvMakeObjectInteractor();
// optionally make it a link interactor
interactor.setLinkMode(true);
// mandatory, set the tag of the created object in the diagrammer model
interactor.setAdditionalParameters("tagname");
view.setInteractor(interactor);
In addition to the tag name, the interactor can be configured to set some initial properties on the selected object at creation time:
 
var properties = {propertyName1: "propertyValue1",
      propertyName2: "propertyValue2"};
interactor.setProperties(properties);
Server-side configuration
To be able to deal with the actions submitted by the IlvMakeObjectInteractor class from the client side, the image Servlet support must be configured by adding the action listener that can handle those actions.
Example:
 
public class DiagrammerServlet extends IlvDiagrammerServlet {
  protected IlvSDMServletSupport createServletSupport(ServletContext context) {
    return new DiagrammerServletSupport(context);
  }
}
 
public class DiagrammerServletSupport extends IlvDiagrammerServletSupport {
  public DiagrammerServletSupport(ServletContext context) {
    super(context);
    addServerActionListener(new IlvDiagrammerCreateActionListener());;
  }
}

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.