|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.servlet.tbeans.models.JavaScriptNode
public class JavaScriptNode
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 |
---|
public JavaScriptNode()
Method Detail |
---|
public java.util.Map getStyleMap()
STYLE KEY | DEFAULT STYLE |
JAVASCRIPTNODE_IMAGE | NONE |
JAVASCRIPTNODE_TEXT | NONE |
JAVASCRIPTNODE_INDENT | NONE |
getStyleMap
in interface JavaScriptNodeInterface
public void setImagesOnly(boolean value)
value
- TRUE to display images only.public boolean isImagesOnly()
public void setNoWrap(boolean value)
setNoWrap
in interface JavaScriptNodeInterface
value
- TRUE to wrap node text.public boolean isNoWrap()
isNoWrap
in interface JavaScriptNodeInterface
public void setImage(java.lang.String value)
setImage
in interface JavaScriptNodeInterface
value
- The source for the imagepublic java.lang.String getImage()
getImage
in interface JavaScriptNodeInterface
public void setDisabledImage(java.lang.String value)
setDisabledImage
in interface JavaScriptNodeInterface
value
- The source for the disabled imagepublic java.lang.String getDisabledImage()
getDisabledImage
in interface JavaScriptNodeInterface
public void setImageLocation(java.lang.String imageLocation)
setImageLocation
in interface JavaScriptNodeInterface
value
- The location for the imagespublic java.lang.String getImageLocation()
getImageLocation
in interface JavaScriptNodeInterface
public void setAlternateText(java.lang.String value)
text
- The alternate text of the imagepublic java.lang.String getAlternateText()
public void setStyleClassPrefix(java.lang.String value)
setStyleClassPrefix
in interface JavaScriptNodeInterface
value
- The style class prefixpublic java.lang.String getStyleClassPrefix()
getStyleClassPrefix
in interface JavaScriptNodeInterface
public void setCloneNodeFunctionName(java.lang.String value)
function sas_Node_nodeClone()
{
......
return clonedNode;
}
setCloneNodeFunctionName
in interface JavaScriptNodeInterface
value
- The clone node function namepublic java.lang.String getCloneNodeFunctionName()
getCloneNodeFunctionName
in interface JavaScriptNodeInterface
public void setSelectNodeFunctionName(java.lang.String value)
function selectNodeFunction()
{
.....
}
setSelectNodeFunctionName
in interface JavaScriptNodeInterface
value
- The select node function namepublic java.lang.String getSelectNodeFunctionName()
getSelectNodeFunctionName
in interface JavaScriptNodeInterface
public void setDeselectNodeFunctionName(java.lang.String value)
function deselectNodeFunction()
{
.....
}
setDeselectNodeFunctionName
in interface JavaScriptNodeInterface
value
- The deselect node function namepublic java.lang.String getDeselectNodeFunctionName()
getDeselectNodeFunctionName
in interface JavaScriptNodeInterface
public void setNodeConstructorName(java.lang.String value)
function sas_Node_BaseNode(args)
{
.....
}
The parameter (args) is an array of properties of the JavaScript that should be initalized
upon creation.
setNodeConstructorName
in interface JavaScriptNodeInterface
value
- The node constructor namepublic java.lang.String getNodeConstructorName()
getNodeConstructorName
in interface JavaScriptNodeInterface
protected static java.lang.String escapeNodeText(java.lang.String nText)
nText
- the string to be reformatted
public java.util.Map getNodeConstructorParameters()
getNodeConstructorParameters
in interface JavaScriptNodeInterface
public java.lang.String createNodeParameterString(java.util.Map params)
createNodeParameterString
in interface JavaScriptNodeInterface
The
- map of node constructor parameters
public void setRenderNodeFunctionName(java.lang.String value)
function sas_Node_nodeRender(_destinationObj)
{
.....
}
The parameter (_destinationObj) is the html/javascript object that you want the node rendered in.
setRenderNodeFunctionName
in interface JavaScriptNodeInterface
value
- The render node function namepublic java.lang.String getRenderNodeFunctionName()
getRenderNodeFunctionName
in interface JavaScriptNodeInterface
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |