|
OpMath | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--java.util.Dictionary
|
+--java.util.Hashtable
|
+--com.opmath.util.datastruct.OrderedHashtable
|
+--com.opmath.util.datastruct.UCHashtable
|
+--com.opmath.util.datastruct.ComparableTable
|
+--com.opmath.util.html.Select
A representation of an HTML <SELECT > structure, compatible with com.opmath.util.datastruct.ComparableTable.
The Select class addresses the problem of regenerating a <SELECT ...> structure - with the
SELECTED tag parameter set on the correct <OPTION...> tags. The Select structure carries
three com.opmath.util.datastruct.ComparableLists, one for each of the three 'dimensions' of the <OPTION...> tags
in the <SELECT ...> structure: NAME, VALUE and optional SELECTED.
To use Select, first create an instance; the minimum specification for this is a
String[] of names:
String[] myNames = { "Natasha", "Bruno", "Mathew" };
Select mySelection = new Select("people", myNames);
To set one of these as SELECTED, do:
mySelection.setSelectedName("Bruno");
To add the result to the document's model, do:
model.register(mySelection);
This last line assumes that the model contains the substitution sources 'peopleNames', 'peopleValues' and 'peopleSelect'. In other words, the HTML template contains something like:
<!-- SUB peopleNames SUB_PEOPLE_NAMES -->
<!-- SUB peopleValues SUB_PEOPLE_VALUES -->
<!-- SUB peopleSelect SUB_PEOPLE_SELECT -->
...
<SELECT NAME="people">
<!-- LOOP -->
<OPTION VALUE="SUB_PEOPLE_VALUES" SUB_PEOPLE_SELECT>SUB_PEOPLE_NAMES</OPTION>
<!-- ENDLOOP -->
</SELECT>
NOTE: The design of the Select class assumes that the names for the SELECT structure
must be unqiue. In contrast, the values for the SELECT structure normally will be unique, but are
not required to be.
Copyright: (c) 2002 The Open Math Company Limited
The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.
| Constructor Summary | |
Select(String id,
String[] names)
Constructs a new Select instance with each OPTION NAME and OPTION VALUE sourced
from the parameter names. |
|
Select(String id,
String[] names,
Comparable[] values)
Constructs a new Select instance with each OPTION NAME sourced
from the parameter names and each OPTION VALUE sourced from the parameter
values. |
|
Select(String id,
String[] names,
Comparable[] values,
String[] select)
Constructs a new Select instance with each OPTION NAME sourced
from the parameter names, each OPTION VALUE sourced from the parameter
values, and each OPTION SELECTED sourced from the parameter
select. |
|
| Method Summary | |
void |
clear()
Sets all the OPTION elements to "" (not selected). |
void |
clearSelectedName(Comparable name)
Sets the OPTION element whose NAME is equal to name to ""
(not selected). |
void |
clearSelectedValue(Comparable value)
Sets the OPTION element whose VALUE is equal to value to ""
(not selected). |
void |
setSelectedName(Comparable name)
Sets the OPTION element whose NAMES is equal to name to "SELECTED". |
void |
setSelectedValue(Comparable value)
Sets the OPTION element whose VALUE is equal to value to "SELECTED". |
| Methods inherited from class com.opmath.util.datastruct.ComparableTable |
addColumn, addColumn, appendObject, appendTo, columnSize, getAt, getColumn, getColumns, getRows, maxColumnSize, register, register, register, registerColumn, sort, sort, toString, updateAt, updateColumn |
| Methods inherited from class com.opmath.util.datastruct.UCHashtable |
normalized |
| Methods inherited from class com.opmath.util.datastruct.OrderedHashtable |
containsKey, elements, get, keys, put, putAll, remove |
| Methods inherited from class java.util.Hashtable |
clone, contains, containsValue, entrySet, equals, hashCode, isEmpty, keySet, rehash, size, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Select(String id,
String[] names)
throws ComparableTableException
Select instance with each OPTION NAME and OPTION VALUE sourced
from the parameter names. The SELECT structure is named id.
The SELECT structure will contain as many OPTION elements as there are elements in
names. Each OPTION element has NAME names[i] and VALUE names[i].
id - the String for the id.names - the String[] for the OPTION elements.
com.opmath.util.datastructure.ComparableTableException - An exception thrown if
the names is null or if names contains non-unique Strings.
ComparableTableException
public Select(String id,
String[] names,
Comparable[] values)
throws ComparableTableException
Select instance with each OPTION NAME sourced
from the parameter names and each OPTION VALUE sourced from the parameter
values. The SELECT structure is named id.
The length of names must equal the length of values. Each OPTION
element has NAME names[i] and VALUE values[i]. Initially,
none of the the OPTION elements are set to SELECTED.
id - the String for the id.names - the String[] for the OPTION element NAMEs.values - the String[] for the OPTION element VALUEs.
com.opmath.util.datastructure.ComparableTableException - An exception thrown if
names or values is null,
if names contains non-unique Strings,
or there is a length mismatch of names / values.
ComparableTableException
public Select(String id,
String[] names,
Comparable[] values,
String[] select)
throws ComparableTableException
Select instance with each OPTION NAME sourced
from the parameter names, each OPTION VALUE sourced from the parameter
values, and each OPTION SELECTED sourced from the parameter
select. The SELECT structure is named id.
The length of names must equal the length of values and the
length of select. Each OPTION element has NAME names[i], VALUE values[i],
and SELECTED select[i]. Each element of select must be set to "" or
"SELECTED".
id - the String for the id.names - the String[] for the OPTION element NAMEs.values - the String[] for the OPTION element VALUES.select - the String[] for the OPTION element SELECTED.
com.opmath.util.datastructure.ComparableTableException - An exception thrown if
names, values or selected is null,
if names contains non-unique Strings,
or there is a length mismatch of names / values / selected.
ComparableTableException| Method Detail |
public void setSelectedValue(Comparable value)
throws ComparableTableException
value to "SELECTED".
All the OPTION element VALUES in a Select should normally be unique. However, if
value identifies a non-unique element, then only the first matching element
is updated.
value - the Comparable identifying the OPTION element.
com.opmath.util.datastructure.ComparableTableException - An exception thrown if
value is null, or value is not in this
Select instance.
ComparableTableException
public void clearSelectedValue(Comparable value)
throws ComparableTableException
value to ""
(not selected).
All the OPTION element VALUES in a Select should normally be unique. However, if
value identifies a non-unique element, then only the first matching element
is updated.
value - the Comparable identifying the OPTION element.
com.opmath.util.datastructure.ComparableTableException - An exception thrown if
value is null, or value is not in this
Select instance.
ComparableTableException
public void setSelectedName(Comparable name)
throws ComparableTableException
name to "SELECTED".
com.opmath.util.datastructure.ComparableTableException - An exception thrown if
name is null, or name is not in this
Select instance.
ComparableTableException
public void clearSelectedName(Comparable name)
throws ComparableTableException
name to ""
(not selected).
com.opmath.util.datastructure.ComparableTableException - An exception thrown if
name is null, or name is not in this
Select instance.
ComparableTableExceptionpublic void clear()
"" (not selected).
clear in interface Mapclear in class ComparableTable
|
OpMath | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||