All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.servlet.tbeans.models
Class JavaScriptNode

    com.sas.servlet.tbeans.models.JavaScriptNode

All Implemented Interfaces:
  ItemInterface, JavaScriptNodeInterface, JavaScriptNodeStyleKeysInterface

Direct Known Subclasses:
  DataItemNode, PercentItemNode, PropertyNode

    public class JavaScriptNode

implements JavaScriptNodeInterface, JavaScriptNodeStyleKeysInterface

`JavaScriptNode` is a generic implementation of `JavaScriptNodeInterface`.

`JavaScriptNode` is used to construct an item that has text and a return value. Along with text and return value, `JavaScriptNode` can contain images that will be displayed along with the text.

A JavaScriptNode is used to construct a node in Java that will be created as a node in JavaScript.

`ComboBoxView` and `ListBoxView` require `JavaScriptNode`s as items populated in the model.

Problem: Create a document using JSP that contains a ComboBox input field.

Solution: Write a Java scriptlet in a JSP page that uses the ComboBox Transformation Bean to create the HTML ComboBox element.

JSP Page:

     <html>
     <LINK REL=STYLESHEET HREF="sasComponents.css" TYPE="text/css">
     <body>

     <p> This example shows a simple ComboBox generated by the ComboBox Transformation Bean. </p>
     <form>
     <%
        // Create a new ComboBox object
        com.sas.servlet.tbeans.form.html.ComboBoxView combobox =
            new com.sas.servlet.tbeans.form.html.ComboBoxView();

        //Create the Nodes
              com.sas.servlet.tbeans.models.JavaScriptNode node1 =
                    new com.sas.servlet.tbeans.models.JavaScriptNode();
            node1.setText("red");
      node1.setImage("folderOpen.gif");

      com.sas.servlet.tbeans.models.JavaScriptNode node2 =
                    new com.sas.servlet.tbeans.models.JavaScriptNode();
            node2.setText("blue");
      node2.setImage("folderOpen.gif");

            com.sas.servlet.tbeans.models.JavaScriptNode node3 =
                    new com.sas.servlet.tbeans.models.JavaScriptNode();
            node3.setText("green");
      node3.setImage("folderOpen.gif");

        // Create the model
        javax.swing.DefaultComboBoxModel model =
            new javax.swing.DefaultComboBoxModel();
        model.addElement(node1);
        model.addElement(node2);
        model.addElement(node3);

        // Set the model
        combobox.setModel(model);

        // Set the selected index
        combobox.setSelectedIndex(1);

        // Output the select
        combobox.write(out);
     %>
     </form>
     </body>
     </html>

HTML output:

     <html>
     <LINK REL=STYLESHEET HREF="sasComponents.css" TYPE="text/css">
     <script language="JavaScript" src="sas_comboBoxView.js"></script>
     <script language="JavaScript" src="sas_listBoxView.js"></script>
     <script language="JavaScript" src="sas_node.js"></script>
     <body>

     <p> This example shows a simple ComboBox generated by the ComboBox Transformation Bean. </p>

     <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
     <TR VALIGN="TOP">
     <TD ALIGN="LEFT">
         <DIV ID='ComboBoxView_0_LabelNode' CLASS='comboBoxViewLabel' STYLE=width:116px; >

     <SCRIPT LANGUAGE='JavaScript'>

     var args = new Array(1);

     args[0] = {render:render,value:"null",image:"folderOpen.gif",text:"red"};

     ComboBoxView_0_node = new JavaScriptNode(args[0]);
     ComboBoxView_0_node.render('ComboBoxView_0_LabelNode');
     </SCRIPT>
         </DIV>
      </TD>
     <TD ALIGN="LEFT">
        <IMG src="/assets/select_up.gif" onMouseDown="this.src='/assets/select_down.gif';
          comboBoxView_showDiv('_ComboBoxView_0_divObject', ListBoxView_2_list, ComboBoxView_0_node);"
          onMouseup="this.src='/assets/select_up.gif'; comboBoxView_setFocus('_ComboBoxView_0_divObject', 'ListBoxView_2', ComboBoxView_0_LabelNode);"
          style="height:100%; width:100%;">
     </TD>
     </TR>
     <TR>
      <TD COLSPAN="2">
        <DIV ID='_ComboBoxView_0_divObject' CLASS="comboBoxViewDropDown" onBlur="comboBoxView_hideDiv('_ComboBoxView_0_divObject', 'ComboBoxView_0_LabelNode');"
          onKeyDown="comboBoxView_changeRow(event, '_ComboBoxView_0_divObject', ListBoxView_2_list,'ComboBoxView_0_LabelNode',ComboBoxView_0_node,true)">
     <DIV ID='ListBoxView_2' CLASS="comboBoxViewList" STYLE=";">

     <SCRIPT LANGUAGE='JavaScript'>

     var args = new Array(4);

     args[0] = {render:render,value:"null",image:"folderOpen.gif",text:"red"};
     args[1] = {render:render,value:"null",image:"folderOpen.gif",text:"blue"};
     args[2] = {render:render,value:"null",image:"folderOpen.gif",text:"green"};

     ListBoxView_2_node1 = new MyJSNode(args[0]);
     ListBoxView_2_node2 = new MyJSNode(args[1]);
     ListBoxView_2_node3 = new MyJSNode(args[2]);

     ListBoxView_2_list = new List('ListBoxView_2_list');
     ListBoxView_2_list.imageLoc='/assets/';
     ListBoxView_2_list.wrapperName="ListBoxView_2";
     ListBoxView_2_list.addItem(ListBoxView_2_node1);
     ListBoxView_2_list.addItem(ListBoxView_2_node2);
     ListBoxView_2_list.addItem(ListBoxView_2_node3);

     ListBoxView_2_list.useMouseDown = true;

     ListBoxView_2_list.useMouseOver = true;

     ListBoxView_2_list.useMouseOut = true;

     ListBoxView_2_list.render();

     function listViewAddMouseDown(node)
     {
        comboBoxView_madeChoice(node, 'ComboBoxView_0_LabelNode', ComboBoxView_0_node)
     }

     function listViewAddMouseOver(node)
     {
        comboBoxView_highlightRow(node);
     }

     function listViewAddMouseOut(node)
     {
        comboBoxView_unhighlightRow(node);
     }

     </SCRIPT>
     </DIV>

     </DIV>
     </TD>
     </TR>
     </TABLE>

Field Summary

Fields inherited from interface com.sas.servlet.tbeans.models.JavaScriptNodeStyleKeysInterface
`JAVASCRIPTNODE_IMAGE, JAVASCRIPTNODE_INDENT, JAVASCRIPTNODE_SELECTED_TEXT, JAVASCRIPTNODE_TEXT`

Constructor Summary
`JavaScriptNode()` Construct a new JSNode

Method Summary
`java.lang.String` | `createNodeParameterString(java.util.Map params)` Returns a String containing the name/value pairs of the properties to be passed to the JavaScript node constructor.
`protected static java.lang.String` | `escapeNodeText(java.lang.String nText)` escapeNodeText reformats the text if a user needs to include quotes or a backslash or newline inside the text.
`java.lang.String` | `getAlternateText()` Gets the alternate text for the image of the JavaScriptNode.
`java.lang.String` | `getCloneNodeFunctionName()` Gets the clone node function name for the JavaScriptNode.
`java.lang.String` | `getDeselectNodeFunctionName()` Gets the deselect node function name for the JavaScriptNode.
`java.lang.String` | `getDisabledImage()` Gets the disabled image source for the JavaScriptNode.
`java.lang.String` | `getImage()` Gets the image source for the JavaScriptNode.
`java.lang.String` | `getImageLocation()` Gets the image location for the JavaScriptNode.
`java.lang.String` | `getNodeConstructorName()` Gets the node constructor name for the JavaScriptNode.
`java.util.Map` | `getNodeConstructorParameters()` Returns a Map containing the name/value pairs of the properties to be passed to the constructor.
`java.lang.String` | `getRenderNodeFunctionName()` Gets the render node function name for the JavaScriptNode.
`java.lang.String` | `getSelectNodeFunctionName()` Gets the select node function name for the JavaScriptNode.
`java.lang.String` | `getStyleClassPrefix()` Gets the style class prefix for the JavaScriptNode.
`java.util.Map` | `getStyleMap()` Returns the style map for this JavaScriptNode.
`boolean` | `isImagesOnly()` Determines if images only should be displayed.
`boolean` | `isNoWrap()` Determines if node text should wrap.
`void` | `setAlternateText(java.lang.String value)` Sets the alternate text for the image of the JavaScriptNode.
`void` | `setCloneNodeFunctionName(java.lang.String value)` Sets the name of the JavaScript function to use to clone this JavaScriptNode.
`void` | `setDeselectNodeFunctionName(java.lang.String value)` Sets the name of the JavaScript function to use when node is deselected.
`void` | `setDisabledImage(java.lang.String value)` Sets the disabled image source for the JavaScriptNode.
`void` | `setImage(java.lang.String value)` Sets the image source for the JavaScriptNode.
`void` | `setImageLocation(java.lang.String imageLocation)` Sets the location of images for the JavaScriptNode.
`void` | `setImagesOnly(boolean value)` Sets whether or not to display images only.
`void` | `setNodeConstructorName(java.lang.String value)` Sets the name of the JavaScript function to use as the constructor for this object.
`void` | `setNoWrap(boolean value)` Sets whether or not to wrap the node text.
`void` | `setRenderNodeFunctionName(java.lang.String value)` Sets the name of the JavaScript function to use to render this object.
`void` | `setSelectNodeFunctionName(java.lang.String value)` Sets the name of the JavaScript function to use when node is selected.
`void` | `setStyleClassPrefix(java.lang.String value)` Sets the style class prefix for the JavaScriptNode.

Methods inherited from class com.sas.servlet.tbeans.models.Item
`getName, getOnBlur, getOnChange, getOnClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseOut, getOnMouseOver, getOnMouseUp, getText, getValue, isSelected, setName, setOnBlur, setOnChange, setOnClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseOut, setOnMouseOver, setOnMouseUp, setSelected, setText, setValue, toString`

Methods inherited from interface com.sas.servlet.tbeans.models.JavaScriptNodeInterface
`getIndentionLevel, getText, getValue, setIndentionLevel, setText, setValue`

Constructor Detail

### JavaScriptNode

    public JavaScriptNode()

  Construct a new JSNode

Method Detail

### getStyleMap

    public java.util.Map getStyleMap()

  Returns the style map for this JavaScriptNode.

  STYLE KEY | DEFAULT STYLE
  JAVASCRIPTNODE_IMAGE | NONE
  JAVASCRIPTNODE_TEXT | NONE
  JAVASCRIPTNODE_INDENT | NONE

  Specified by:
    `getStyleMap` in interface `JavaScriptNodeInterface`
  Returns:
    styles used for this JavaScriptNode

### setImagesOnly

    public void setImagesOnly(boolean value)

  Sets whether or not to display images only. By default if you only set image and value on a node, the display text is set to value. By setting this method to TRUE, the display text will NOT be set to value. FALSE by default.

  Parameters:
    `value` - TRUE to display images only.

### isImagesOnly

    public boolean isImagesOnly()

  Determines if images only should be displayed.

  Returns:
    TRUE if images only are displayed.

### setNoWrap

    public void setNoWrap(boolean value)

  Sets whether or not to wrap the node text. FALSE by default.

  Specified by:
    `setNoWrap` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - TRUE to wrap node text.

### isNoWrap

    public boolean isNoWrap()

  Determines if node text should wrap.

  Specified by:
    `isNoWrap` in interface `JavaScriptNodeInterface`
  Returns:
    TRUE if node text should wrap.

### setImage

    public void setImage(java.lang.String value)

  Sets the image source for the JavaScriptNode.

  Specified by:
    `setImage` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The source for the image

### getImage

    public java.lang.String getImage()

  Gets the image source for the JavaScriptNode.

  Specified by:
    `getImage` in interface `JavaScriptNodeInterface`
  Returns:
    The source of the image

### setDisabledImage

    public void setDisabledImage(java.lang.String value)

  Sets the disabled image source for the JavaScriptNode.

  Specified by:
    `setDisabledImage` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The source for the disabled image

### getDisabledImage

    public java.lang.String getDisabledImage()

  Gets the disabled image source for the JavaScriptNode.

  Specified by:
    `getDisabledImage` in interface `JavaScriptNodeInterface`
  Returns:
    The source of the disabled image

### setImageLocation

    public void setImageLocation(java.lang.String imageLocation)

  Sets the location of images for the JavaScriptNode.

  Specified by:
    `setImageLocation` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The location for the images

### getImageLocation

    public java.lang.String getImageLocation()

  Gets the image location for the JavaScriptNode.

  Specified by:
    `getImageLocation` in interface `JavaScriptNodeInterface`
  Returns:
    The location of the images

### setAlternateText

    public void setAlternateText(java.lang.String value)

  Sets the alternate text for the image of the JavaScriptNode.

  Parameters:
    `text` - The alternate text of the image

### getAlternateText

    public java.lang.String getAlternateText()

  Gets the alternate text for the image of the JavaScriptNode.

  Returns:
    The alternate text of the image

### setStyleClassPrefix

    public void setStyleClassPrefix(java.lang.String value)

  Sets the style class prefix for the JavaScriptNode.

  Specified by:
    `setStyleClassPrefix` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The style class prefix

### getStyleClassPrefix

    public java.lang.String getStyleClassPrefix()

  Gets the style class prefix for the JavaScriptNode.

  Specified by:
    `getStyleClassPrefix` in interface `JavaScriptNodeInterface`
  Returns:
    The style class prefix

### setCloneNodeFunctionName

    public void setCloneNodeFunctionName(java.lang.String value)

  Sets the name of the JavaScript function to use to clone this JavaScriptNode. This function should clone the node the method is called on. The function should look similar to `function sas_Node_nodeClone() { ...... return clonedNode; }`

  Specified by:
    `setCloneNodeFunctionName` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The clone node function name

### getCloneNodeFunctionName

    public java.lang.String getCloneNodeFunctionName()

  Gets the clone node function name for the JavaScriptNode.

  Specified by:
    `getCloneNodeFunctionName` in interface `JavaScriptNodeInterface`
  Returns:
    The clone node function name

### setSelectNodeFunctionName

    public void setSelectNodeFunctionName(java.lang.String value)

  Sets the name of the JavaScript function to use when node is selected. This function should update the style of the selected node to differentiate it from nodes which are not selected, for example by highlighting it. The function should look similar to `function selectNodeFunction() { ..... }`

  Specified by:
    `setSelectNodeFunctionName` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The select node function name

### getSelectNodeFunctionName

    public java.lang.String getSelectNodeFunctionName()

  Gets the select node function name for the JavaScriptNode.

  Specified by:
    `getSelectNodeFunctionName` in interface `JavaScriptNodeInterface`
  Returns:
    The select node function name

### setDeselectNodeFunctionName

    public void setDeselectNodeFunctionName(java.lang.String value)

  Sets the name of the JavaScript function to use when node is deselected. This function should update the style of the deselected node to differentiate it from nodes which are selected, for example by unhighlighting it. The function should look similar to `function deselectNodeFunction() { ..... }`

  Specified by:
    `setDeselectNodeFunctionName` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The deselect node function name

### getDeselectNodeFunctionName

    public java.lang.String getDeselectNodeFunctionName()

  Gets the deselect node function name for the JavaScriptNode.

  Specified by:
    `getDeselectNodeFunctionName` in interface `JavaScriptNodeInterface`
  Returns:
    The deselect node function name

### setNodeConstructorName

    public void setNodeConstructorName(java.lang.String value)

  Sets the name of the JavaScript function to use as the constructor for this object. This function should create the JavaScriptNode along with initalizing parameters set by the user. The function should look similar to `function sas_Node_BaseNode(args) { ..... }` The parameter (args) is an array of properties of the JavaScript that should be initalized upon creation.

  Specified by:
    `setNodeConstructorName` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The node constructor name

### getNodeConstructorName

    public java.lang.String getNodeConstructorName()

  Gets the node constructor name for the JavaScriptNode.

  Specified by:
    `getNodeConstructorName` in interface `JavaScriptNodeInterface`
  Returns:
    The node constructor function name

### escapeNodeText

    protected static java.lang.String escapeNodeText(java.lang.String nText)

  escapeNodeText reformats the text if a user needs to include quotes or a backslash or newline inside the text. It will run the text through Strings.quoteForXML() and Strings.escapeForJavaScript().

  Parameters:
    `nText` - the string to be reformatted
  Returns:
    String the reformatted string

### getNodeConstructorParameters

    public java.util.Map getNodeConstructorParameters()

  Returns a Map containing the name/value pairs of the properties to be passed to the constructor.

  Specified by:
    `getNodeConstructorParameters` in interface `JavaScriptNodeInterface`
  Returns:
    parameters The node constructor parameters

### createNodeParameterString

    public java.lang.String createNodeParameterString(java.util.Map params)

  Returns a String containing the name/value pairs of the properties to be passed to the JavaScript node constructor.

  Specified by:
    `createNodeParameterString` in interface `JavaScriptNodeInterface`
  Parameters:
    `The` - map of node constructor parameters
  Returns:
    The JavaScript representation of the node constructor parameters

### setRenderNodeFunctionName

    public void setRenderNodeFunctionName(java.lang.String value)

  Sets the name of the JavaScript function to use to render this object. This function should render the JavaScriptNode to be viewed in the browser, for example by creating a table that makes up the JavaScriptNode. The function should look similar to `function sas_Node_nodeRender(_destinationObj) { ..... }` The parameter (_destinationObj) is the html/javascript object that you want the node rendered in.

  Specified by:
    `setRenderNodeFunctionName` in interface `JavaScriptNodeInterface`
  Parameters:
    `value` - The render node function name

### getRenderNodeFunctionName

    public java.lang.String getRenderNodeFunctionName()

  Gets the render node function name for the JavaScriptNode.

  Specified by:
    `getRenderNodeFunctionName` in interface `JavaScriptNodeInterface`
  Returns:
    The render node function name

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.