org.apache.turbine.util.template
Class SelectorBox
java.lang.Object
|
+--org.apache.turbine.util.template.SelectorBox
- public class SelectorBox
- extends java.lang.Object
This class is for generating a SelectorBox. It is good when used
with WM because you can stuff it into the context and then just
call it to generate the HTML. It can be used in other cases as
well, but WM is the best case for it right now.
For example code showing the usage for this module, please see
the toString() method below to see how it would be refered to from
WM.
// get the roles for a user
RoleSet userRoles = new DefaultAccessControl().getRoles(loginid, null);
if ( userRoles != null )
{
context.put("hasRoleSet", Boolean.TRUE);
// get an array of the users roles
Role[] usersRoles = userRoles.getRolesArray();
// get an array of all the roles in the system
Role[] allRoles = ((RoleSet)RolePeer.retrieveSet()).getRolesArray();
Object[] names = new Object[allRoles.length];
Object[] values = new Object[allRoles.length];
for ( int i=0;i
- Version:
- $Id$
- Author:
- Jon S. Stevens
Field Summary |
private java.lang.String |
name
This is the name= value. |
private java.lang.Object[] |
names
This is the value= portion of the option element. |
private org.apache.ecs.html.Select |
sel
This is the Select ECS element. |
private boolean[] |
selected
This is an array of which items are selected. |
private int |
size
This is the size of the Select statement. |
private java.lang.Object[] |
values
This is the data after the option element. |
Constructor Summary |
SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values)
Generic constructor, builds a select box with a default size of
1 and no selected items. |
SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values,
boolean[] selected)
Generic constructor builds a select box. |
SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values,
int size)
Generic constructor builds a select box. |
SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values,
int size,
boolean[] selected)
Primary constructor for everything. |
Method Summary |
void |
buildBooleans(java.lang.Object[] selectedSet,
java.lang.Object[] entireSet)
Pass in an array of selected items and the entire set of items
and it will determine which items in the selected set are also
in the entireset and then build a boolean[] up that is the same
size as the entireSet with markings to tell whether or not the
items are marked or not. |
void |
reset()
Resets the internal state of the SelectorBox. |
SelectorBox |
setMultiple(boolean val)
This allows you to set the multiple attribute to the select
element. |
SelectorBox |
setName(java.lang.String name)
This allows one to set the name= attribute to the select
element. |
SelectorBox |
setOnChange(java.lang.String script)
This allows one to set an onChange attribute on the select tag |
SelectorBox |
setSelected(boolean[] bools)
This allows one to set the array of selected booleans. |
SelectorBox |
setSize(int size)
This allows one to set the size of the select element. |
java.lang.String |
toString()
This builds out the select box at a certain size. |
java.lang.String |
toString(int size)
This builds out the select box at a certain size. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
sel
private org.apache.ecs.html.Select sel
- This is the Select ECS element.
size
private int size
- This is the size of the Select statement.
name
private java.lang.String name
- This is the name= value.
names
private java.lang.Object[] names
- This is the value= portion of the option element.
values
private java.lang.Object[] values
- This is the data after the option element.
selected
private boolean[] selected
- This is an array of which items are selected.
SelectorBox
public SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values)
- Generic constructor, builds a select box with a default size of
1 and no selected items.
- Parameters:
name
- A String with the name for the select box.names
- An Object[] with the names.values
- An Object[] with the values.
SelectorBox
public SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values,
int size)
- Generic constructor builds a select box.
- Parameters:
name
- A String with the name for the select box.names
- An Object[] with the names.values
- An Object[] with the values.size
- An int specifying the size.
SelectorBox
public SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values,
boolean[] selected)
- Generic constructor builds a select box.
- Parameters:
name
- A String with the name for the select box.names
- An Object[] with the names.values
- An Object[] with the values.selected
- A boolean[] with the selected items.
SelectorBox
public SelectorBox(java.lang.String name,
java.lang.Object[] names,
java.lang.Object[] values,
int size,
boolean[] selected)
- Primary constructor for everything.
- Parameters:
name
- A String with the name for the select box.names
- An Object[] with the names.values
- An Object[] with the values.size
- An int specifying the size.selected
- A boolean[] with the selected items.
buildBooleans
public void buildBooleans(java.lang.Object[] selectedSet,
java.lang.Object[] entireSet)
- Pass in an array of selected items and the entire set of items
and it will determine which items in the selected set are also
in the entireset and then build a boolean[] up that is the same
size as the entireSet with markings to tell whether or not the
items are marked or not. It uses toString().equalsIgnoreCase()
on the Object in the Object[] to determine if the items are
equal.
- Parameters:
selectedSet
- An Object[].entireSet
- An Object[].
toString
public java.lang.String toString(int size)
- This builds out the select box at a certain size. To use this
element in WM, you simply build this object in your java code,
put it into the context and then call $selectBox.toString(5).
- Parameters:
size
- An int with the size.- Returns:
- A String with the HTML code.
reset
public void reset()
- Resets the internal state of the SelectorBox.
toString
public java.lang.String toString()
- This builds out the select box at a certain size. To use this
element in WM, you simply build this object in your java code,
put it into the context and then call $selectBox and it will
build it with the default size of 1.
- Overrides:
toString
in class java.lang.Object
- Returns:
- A String with the HTML code.
setMultiple
public SelectorBox setMultiple(boolean val)
- This allows you to set the multiple attribute to the select
element. Example usage from within WM is like this:
$selectBox.setMultiple(true).toString(4)
- Parameters:
val
- True if multiple selection should be allowed.- Returns:
- A SelectorBox (self).
setName
public SelectorBox setName(java.lang.String name)
- This allows one to set the name= attribute to the select
element.
- Parameters:
name
- A String with the name.- Returns:
- A SelectorBox (self).
setSize
public SelectorBox setSize(int size)
- This allows one to set the size of the select element.
- Parameters:
size
- An int with the size.- Returns:
- A SelectorBox (self).
setOnChange
public SelectorBox setOnChange(java.lang.String script)
- This allows one to set an onChange attribute on the select tag
- Parameters:
script
- A string with the script to put in onChange- Returns:
- A SelectorBox (self).
setSelected
public SelectorBox setSelected(boolean[] bools)
- This allows one to set the array of selected booleans.
- Parameters:
an
- array of booleans- Returns:
- A SelectorBox (self).
Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.