public class SelectorBox extends Object
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<allRoles.length; i++ ) { names[i] = Integer.valueOf(allRoles[i].getPrimaryKey()).toString(); values[i] = allRoles[i].getName(); } SelectorBox sb = new SelectorBox("roleSetBox", names, values); sb.buildBooleans(usersRoles, allRoles); context.put("roleSetBox", sb); } else { context.put("hasRoleSet", Boolean.FALSE); }
Constructor and Description |
---|
SelectorBox(String name,
Object[] names,
Object[] values)
Generic constructor, builds a select box with a default size of
1 and no selected items.
|
SelectorBox(String name,
Object[] names,
Object[] values,
boolean[] selected)
Generic constructor builds a select box.
|
SelectorBox(String name,
Object[] names,
Object[] values,
int size)
Generic constructor builds a select box.
|
SelectorBox(String name,
Object[] names,
Object[] values,
int size,
boolean[] selected)
Primary constructor for everything.
|
Modifier and Type | Method and Description |
---|---|
void |
buildBooleans(Object[] selectedSet,
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(String name)
This allows one to set the name= attribute to the select
element.
|
SelectorBox |
setOnChange(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 |
setSelected(Object name)
This will set all elements as unselected, except for the
element(s) with the given name.
|
SelectorBox |
setSize(int size)
This allows one to set the size of the select element.
|
String |
toString()
This builds out the select box at a certain size.
|
String |
toString(int size)
This builds out the select box at a certain size.
|
public SelectorBox(String name, Object[] names, Object[] values)
name
- A String with the name for the select box.names
- An Object[] with the names.values
- An Object[] with the values.public SelectorBox(String name, Object[] names, Object[] values, int size)
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.public SelectorBox(String name, Object[] names, Object[] values, boolean[] selected)
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.public SelectorBox(String name, Object[] names, Object[] values, int size, boolean[] selected)
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.public void buildBooleans(Object[] selectedSet, Object[] entireSet)
selectedSet
- An Object[].entireSet
- An Object[].public String toString(int size)
size
- An int with the size.public void reset()
public String toString()
public SelectorBox setMultiple(boolean val)
$selectBox.setMultiple(true).toString(4)
val
- True if multiple selection should be allowed.public SelectorBox setName(String name)
name
- A String with the name.public SelectorBox setSize(int size)
size
- An int with the size.public SelectorBox setOnChange(String script)
script
- A string with the script to put in onChangepublic SelectorBox setSelected(boolean[] bools)
bools
- an array of booleanspublic SelectorBox setSelected(Object name)
name
- The name to appear as selected.Copyright © 2000-2015 The Apache Software Foundation. All Rights Reserved.