|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.servlet.tbeans.models.Item
public class Item
Item
is a generic implementation of ItemInterface
.
Item
is used to construct an item that has text and a return value.
Item
is the base class for JavaScriptNode
.
Item
is commonly used in a ChoiceBox, ListBox, and Radio to replace the need for
having to specify two models ( Model and DescriptionModel) in order to have the components display
one text while returning another.
Problem: Create a document using JSP that contains a ChoiceBox input field populated with items.
Solution: Write a Java scriptlet in a JSP page that uses the ChoiceBox Transformation Bean to create the HTML choicebox element.
JSP Page:
<html> <body> <p> This example shows a simple choicebox generated by the ChoiceBox Transformation Bean. </p> <form> <% // Create a new choicebox object com.sas.servlet.tbeans.form.html.ChoiceBox choicebox = new com.sas.servlet.tbeans.form.html.ChoiceBox();
//Create the Items com.sas.servlet.tbeans.models.Item item1 = new com.sas.servlet.tbeans.models.Item(); item1.setText("Red"); item1.setValue("R"); com.sas.servlet.tbeans.models.Item item2 = new com.sas.servlet.tbeans.models.Item(); item2.setText("Green"); item2.setValue("G"); com.sas.servlet.tbeans.models.Item item3 = new com.sas.servlet.tbeans.models.Item(); item3.setText("Orange"); item3.setValue("O");
// Create the model javax.swing.ComboBoxModel model = new javax.swing.DefaultComboBoxModel(); ((javax.swing.DefaultComboBoxModel)model).addElement(item1); ((javax.swing.DefaultComboBoxModel)model).addElement(item2); ((javax.swing.DefaultComboBoxModel)model).addElement(item3); // Set the model choicebox.setModel(model);
// Set the selected index choicebox.setSelectedIndex(1);
// Output the select choicebox.write(out); %> </form> </body> </html>
HTML output:
<html> <body> <p> This example shows a simple choicebox generated by the ChoiceBox Transformation Bean. </p> <select name="ChoiceBox" size="1"> <option value="R">Red</option> <option selected="selected" value="G">Green</option> <option value="O">Orange</option> </select> </body> </html>
Live element:
Constructor Summary | |
---|---|
Item()
Construct a new Item |
|
Item(java.lang.String text)
Construct a new Item with text |
|
Item(java.lang.String text,
java.lang.String value)
Construct a new Item with text and value |
Method Summary | |
---|---|
java.lang.String |
getName()
Gets the name that will be used to identify the Item |
java.lang.String |
getOnBlur()
Gets the onBlur value. |
java.lang.String |
getOnChange()
Gets the onChange value. |
java.lang.String |
getOnClick()
Gets the onClick value. |
java.lang.String |
getOnFocus()
Gets the onFocus value. |
java.lang.String |
getOnKeyDown()
Gets the onKeyDown value |
java.lang.String |
getOnKeyPress()
Gets the onKeyPress value |
java.lang.String |
getOnKeyUp()
Gets the onKeyUp value |
java.lang.String |
getOnMouseDown()
Gets the onMouseDown value |
java.lang.String |
getOnMouseOut()
Gets the onMouseOut value. |
java.lang.String |
getOnMouseOver()
Gets the onMouseOver value. |
java.lang.String |
getOnMouseUp()
Gets the onMouseUp value |
java.lang.String |
getText()
Gets the text of the Item. |
java.lang.String |
getValue()
Gets the return value for the Item. |
boolean |
isSelected()
Gets the selected property of the Item. |
void |
setName(java.lang.String value)
Sets the name that will be used to identify the Item |
void |
setOnBlur(java.lang.String value)
Sets the onBlur event for the item. |
void |
setOnChange(java.lang.String value)
Sets the onChange event for the item. |
void |
setOnClick(java.lang.String value)
Sets the onClick event for the item. |
void |
setOnFocus(java.lang.String value)
Sets the onFocus event for the item. |
void |
setOnKeyDown(java.lang.String value)
Sets the onKeyDown event for the item. |
void |
setOnKeyPress(java.lang.String value)
Sets the onKeyPress event for the item. |
void |
setOnKeyUp(java.lang.String value)
Sets the onKeyUp event for the item. |
void |
setOnMouseDown(java.lang.String value)
Sets the onMouseDown event for the item. |
void |
setOnMouseOut(java.lang.String value)
Sets the onMouseOut event for the item. |
void |
setOnMouseOver(java.lang.String value)
Sets the onMouseOver event for the item. |
void |
setOnMouseUp(java.lang.String value)
Sets the onMouseUp event for the item. |
void |
setSelected(boolean b)
Sets the selected property (boolean). |
void |
setText(java.lang.String value)
Sets the text of the Item. |
void |
setValue(java.lang.String value)
Sets the return value for the Item. |
java.lang.String |
toString()
Returns the value of the text property. |
Constructor Detail |
---|
public Item()
public Item(java.lang.String text)
text
- The Item's textpublic Item(java.lang.String text, java.lang.String value)
text
- The Item's textvalue
- The Item's return valueMethod Detail |
---|
public void setName(java.lang.String value)
value
- The name used to identify the Itempublic java.lang.String getName()
public void setText(java.lang.String value)
setText
in interface ItemInterface
value
- The text the Item displayspublic java.lang.String getText()
getText
in interface ItemInterface
public void setValue(java.lang.String value)
setValue
in interface ItemInterface
value
- The return valuepublic java.lang.String getValue()
getValue
in interface ItemInterface
public java.lang.String toString()
toString
in class java.lang.Object
public void setSelected(boolean b)
selected
- Specifies whether or not the item is selected.public boolean isSelected()
public void setOnBlur(java.lang.String value)
setOnBlur
in interface ItemInterface
value
- The onBlur eventpublic java.lang.String getOnBlur()
getOnBlur
in interface ItemInterface
public void setOnChange(java.lang.String value)
setOnChange
in interface ItemInterface
value
- The onChange eventpublic java.lang.String getOnChange()
getOnChange
in interface ItemInterface
public void setOnClick(java.lang.String value)
setOnClick
in interface ItemInterface
value
- The onClick eventpublic java.lang.String getOnClick()
getOnClick
in interface ItemInterface
public void setOnFocus(java.lang.String value)
setOnFocus
in interface ItemInterface
value
- The onFocus eventpublic java.lang.String getOnFocus()
getOnFocus
in interface ItemInterface
public void setOnMouseOut(java.lang.String value)
setOnMouseOut
in interface ItemInterface
value
- The onMouseOut eventpublic java.lang.String getOnMouseOut()
getOnMouseOut
in interface ItemInterface
public void setOnMouseOver(java.lang.String value)
setOnMouseOver
in interface ItemInterface
value
- The onMouseOver eventpublic java.lang.String getOnMouseOver()
getOnMouseOver
in interface ItemInterface
public void setOnMouseDown(java.lang.String value)
setOnMouseDown
in interface ItemInterface
value
- The onMouseDown eventpublic java.lang.String getOnMouseDown()
getOnMouseDown
in interface ItemInterface
public void setOnMouseUp(java.lang.String value)
setOnMouseUp
in interface ItemInterface
value
- The onMouseUp eventpublic java.lang.String getOnMouseUp()
getOnMouseUp
in interface ItemInterface
public void setOnKeyDown(java.lang.String value)
setOnKeyDown
in interface ItemInterface
value
- The onKeyDown eventpublic java.lang.String getOnKeyDown()
getOnKeyDown
in interface ItemInterface
public void setOnKeyPress(java.lang.String value)
setOnKeyPress
in interface ItemInterface
value
- The onKeyPress eventpublic java.lang.String getOnKeyPress()
getOnKeyPress
in interface ItemInterface
public void setOnKeyUp(java.lang.String value)
setOnKeyUp
in interface ItemInterface
value
- The onKeyUp eventpublic java.lang.String getOnKeyUp()
getOnKeyUp
in interface ItemInterface
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |