com.sas.servlet.beans.javascript
Class TreeControl

java.lang.Object
  |
  +--com.sas.Component
        |
        +--com.sas.servlet.beans.BaseTransformation
              |
              +--com.sas.servlet.beans.javascript.TreeControl

public class TreeControl
extends BaseTransformation
implements TreeControlInterface

Transformation bean for creating JavaScript tree controls. The TreeControl Transformation Bean requires a model that implements com.sas.sasserver.jstree.JSTreeNodesInterface.

Example 1:

The following example illustrates the use of the TreeControl Transformation Bean.

JSP Page:

 <html>
 <head>
 <title>TreeControl Bean</title>
 <body>
 <p>
 <%
  com.sas.model.SimpleJSTreeNode rootNode = 
     new com.sas.model.SimpleJSTreeNode("rootNode","James Goodnight","/jsp/empclick.jsp?name=\"James Goodnight\"&position=\"President\"");
  com.sas.model.SimpleJSTreeNode node1 = 
     new com.sas.model.SimpleJSTreeNode("node1","Barrett Joyner","/jsp/empclick.jsp?name=\"Barrett Joyner\"&position=\"Vice President\"");
  rootNode.addChild(node1);
  com.sas.model.SimpleJSTreeNode node2 = 
     new com.sas.model.SimpleJSTreeNode("node2","David Septoff","/jsp/empclick.jsp?name=\"David Septoff\"&position=\"Consulting Manager\"");
  node1.addChild(node2);
  com.sas.model.SimpleJSTreeNode node3 = 
     new com.sas.model.SimpleJSTreeNode("node3","Jim Wilkerson","/jsp/empclick.jsp?name=\"Jim Wilkerson\"&position=\"Region Consulting Manager\"");      
  node2.addChild(node3);
  com.sas.model.SimpleJSTreeNode node4 = 
     new com.sas.model.SimpleJSTreeNode("node4","Jacki Iverson","/jsp/empclick.jsp?name=\"Jackie Iverson\"&position=\"Consultant\"");      
  node3.addChild(node4);   
  com.sas.model.SimpleJSTreeNode node5 = 
     new com.sas.model.SimpleJSTreeNode("node5","Margorie Lampton","/jsp/empclick.jsp?name=\"Margorie Lampton\"&position=\"Consultant\"");      
  node3.addChild(node4);
  com.sas.model.SimpleJSTreeNode node6 = 
     new com.sas.model.SimpleJSTreeNode("node6","Kelly Ross","/jsp/empclick.jsp?name=\"Kelly Ross\"&position=\"Region Sales Manager\"");      
  node1.addChild(node6);      
  com.sas.model.SimpleJSTreeNode node7 = 
     new com.sas.model.SimpleJSTreeNode("node7","Marshall Scott","/jsp/empclick.jsp?name=\"Marshall Scott\"&position=\"District Sales Manager\"");      
  node6.addChild(node7);      
  com.sas.model.SimpleJSTreeNode node8 = 
     new com.sas.model.SimpleJSTreeNode("node8","Vikki Katz","/jsp/empclick.jsp?name=\"Vikki Katz\"&position=\"Account Rep\"");      
  node7.addChild(node8);
  com.sas.model.SimpleJSTreeNode node9 = 
     new com.sas.model.SimpleJSTreeNode("node9","Brad Jackson","/jsp/empclick.jsp?name=\"Brad Jackson\"&position=\"ECS\"");      
  node7.addChild(node9);
  
  //Create the TreeControl
 
  com.sas.servlet.beans.javascript.TreeControl tc = 
        new com.sas.servlet.beans.javascript.TreeControl();
           
  tc.setModelInterface(rootNode);
  tc.setImagesLocation("images/");
  tc.write(out);

 %>
 </body>
 </html>
 

Display the Tree

Example 2:

This example shows how to use the TreeControl using a com.sas.sasserver.JSTreeInterface as a model.

The TreeControl can use any model that implements the com.sas.sasserver.JSTreeNodes interface. Currently, there are two such models the com.sas.models.SimpleJSTreeNode class and the com.sas.sasserver.JSTreeInterface.

You can use the makeorg sas program to create the SASUSER.SASORG data set used in this example.

The data set used with the com.sas.sasserver.JSTreeInterface must be a level data set. If you have a SAS data set that contains data stored using a parent/child hierarchical format, you can use the pctolvl macro to convert the parent/child data set to a level data set.

JSP Page:


 <html>
 <head>
 <title>TreeControl Bean</title>
 </head>
 <body>
 <%
    com.sas.rmi.Connection connection = new com.sas.rmi.Connection();
    connection.setHost("localhost");
    
    //Add the next two statements if you are using the middleware server
    //connection.setFunnelHost("localhost");
    //connection.setFunnel(true);
    
    com.sas.rmi.Rocf rocf = new com.sas.rmi.Rocf();
    
    
          com.sas.sasserver.jstree.JSTreeInterface treeModel =
         (com.sas.sasserver.jstree.JSTreeInterface)
        com.sas.servlet.util.Util.newInstance(rocf, connection, 
 	           com.sas.sasserver.jstree.JSTreeInterface.class);
         
          
          treeModel.setDataSet("sasuser.sasorg");
          treeModel.setTextColumn("text");
          treeModel.setLevelColumn("level");
          treeModel.setIndexColumn("index");
          treeModel.setLink("empclick.jsp");
          treeModel.setDefaultIcon("folderClosed.gif");
          treeModel.setExpandedIcon("folderOpen.gif");
          String nvps[] = new String[2];
          nvps[0]="NAME";
          nvps[1]="TITLE"; 
          treeModel.setNameValuePairColumns(nvps);
          com.sas.servlet.beans.javascript.TreeControl tc = 
             new com.sas.servlet.beans.javascript.TreeControl();
          tc.setDisplayStyle(com.sas.servlet.beans.javascript.TreeControlInterface.IMAGES);
          tc.setUseTextAsLink(true);   
          tc.setModelInterface(treeModel);
          tc.setImagesLocation("images/");
          tc.write(out);
          //Remove the next statement if you are using the middleware server
          rocf.stop();
    
          
 %>
 
 </body>
 </html>
 

Display the Tree

See Also:
TreeControlInterface, JSTreeNodesInterface, SimpleJSTreeNode, JSTreeInterface, Serialized Form

Constructor Summary
TreeControl()
          Construct a new TreeControl object
TreeControl(String name)
          Construct a new TreeControl object
 
Method Summary
 int getDisplayStyle()
          Returns the display style for the tree.
 String getFrame()
          Returns the value of the FRAME= argument used on the anchor tags generated.
 String getImagesLocation()
          Returns the location(directory) of the images needed to construct the Tree.
 Vector getRequiredInterfaces()
          Sets the required interface that a model must implement in order to attach to this bean Models must implement com.sas.models.TreeInterface in order to be used by this transformation bean
 boolean getUseTextAsLink()
          Returns whether or not the text descriptions in the tree are links or plain text.
 void setDisplayStyle(int style)
          Sets the display style for the tree.
 void setFrame(String frm)
          Sets the value of the FRAME= argument used on the anchor tags generated.
 void setImagesLocation(String imageLocation)
          Sets the location(web server defined directory) of the images needed to construct the Tree.
 void setUseTextAsLink(boolean textAsLink)
          Determines if the text descriptions in the tree are links or plain text.
 void write(PrintWriter out)
          Writes the transformed representation of the object
 
Methods inherited from class com.sas.servlet.beans.BaseTransformation
getCustomAttributes, getDescription, getName, getParent, getRequest, getResponse, setCustomAttributes, setDescription, setName, setParent, setRequest, setResponse, toString, write, write, write
 
Methods inherited from class com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getExtendedBeanInfo, getLinkInfo, getModelInterface, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeControl

public TreeControl()
Construct a new TreeControl object

TreeControl

public TreeControl(String name)
Construct a new TreeControl object
Parameters:
name - The name of the TreeControl
Method Detail

getRequiredInterfaces

public Vector getRequiredInterfaces()
Sets the required interface that a model must implement in order to attach to this bean Models must implement com.sas.models.TreeInterface in order to be used by this transformation bean
Returns:
An array of interface names
Overrides:
getRequiredInterfaces in class Component

getDisplayStyle

public int getDisplayStyle()
Returns the display style for the tree. The two possible values for display style are NO_IMAGES and IMAGES.
Specified by:
getDisplayStyle in interface TreeControlInterface
Returns:
the display style for the tree.

setDisplayStyle

public void setDisplayStyle(int style)
Sets the display style for the tree. The possible values are NO_IMAGES and IMAGES.
Specified by:
setDisplayStyle in interface TreeControlInterface
Parameters:
style - - the new value for the display style

getImagesLocation

public String getImagesLocation()
Returns the location(directory) of the images needed to construct the Tree. The location can be a fully qualified URL or a relative location.
Specified by:
getImagesLocation in interface TreeControlInterface
Returns:
the location of the needed images

setImagesLocation

public void setImagesLocation(String imageLocation)
Sets the location(web server defined directory) of the images needed to construct the Tree. The location can be a fully qualified URL or a relative location.
Specified by:
setImagesLocation in interface TreeControlInterface
Parameters:
imageLocation - - the location of the needed images

getUseTextAsLink

public boolean getUseTextAsLink()
Returns whether or not the text descriptions in the tree are links or plain text.
Specified by:
getUseTextAsLink in interface TreeControlInterface
Returns:
true if text descriptions are displayed as links, false otherwise.
See Also:
TreeControlInterface.setUseTextAsLink(boolean), TreeControlInterface.setDisplayStyle(int)

setUseTextAsLink

public void setUseTextAsLink(boolean textAsLink)
Determines if the text descriptions in the tree are links or plain text.
Specified by:
setUseTextAsLink in interface TreeControlInterface
Parameters:
textAsLink - - true to use the text descriptions as links, false otherwise.
See Also:
TreeControlInterface.setDisplayStyle(int), TreeControlInterface.getUseTextAsLink()

getFrame

public String getFrame()
Returns the value of the FRAME= argument used on the anchor tags generated. This value determines where/how the links associated with the nodes on the tree are displayed. The default value is _blank which will cause a new browser window to be opened each time a node is clicked on.
Specified by:
getFrame in interface TreeControlInterface
Returns:
FRAME= argument of each folders anchor tag.
See Also:
TreeControlInterface.setFrame(java.lang.String)

setFrame

public void setFrame(String frm)
Sets the value of the FRAME= argument used on the anchor tags generated. This value determines where/how the links associated with the nodes on the tree are displayed. The default value is _blank which will cause a new browser window to be opened each time a node is clicked on.
Specified by:
setFrame in interface TreeControlInterface
Returns:
FRAME= argument of each folders anchor tag.
See Also:
TreeControlInterface.getFrame()

write

public void write(PrintWriter out)
           throws IOException
Writes the transformed representation of the object
Parameters:
out - The output stream
Overrides:
write in class BaseTransformation


Version: 1.2.20000317.001 Formatted: 2000/07/06 15:57:33PM