|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sas.Component | +--com.sas.servlet.beans.BaseTransformation | +--com.sas.servlet.beans.javascript.TreeControl
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>
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>
TreeControlInterface
,
JSTreeNodesInterface
,
SimpleJSTreeNode
,
JSTreeInterface
, Serialized FormConstructor 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 java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public TreeControl()
public TreeControl(String name)
name
- The name of the TreeControlMethod Detail |
public Vector getRequiredInterfaces()
public int getDisplayStyle()
public void setDisplayStyle(int style)
style
- - the new value for the display stylepublic String getImagesLocation()
public void setImagesLocation(String imageLocation)
imageLocation
- - the location of the needed imagespublic boolean getUseTextAsLink()
TreeControlInterface.setUseTextAsLink(boolean)
,
TreeControlInterface.setDisplayStyle(int)
public void setUseTextAsLink(boolean textAsLink)
textAsLink
- - true to use the text descriptions as links, false otherwise.TreeControlInterface.setDisplayStyle(int)
,
TreeControlInterface.getUseTextAsLink()
public String getFrame()
TreeControlInterface.setFrame(java.lang.String)
public void setFrame(String frm)
TreeControlInterface.getFrame()
public void write(PrintWriter out) throws IOException
out
- The output stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |