|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.click.control.AbstractControl
net.sf.click.control.Field
net.sf.click.extras.control.PickList
public class PickList
Provides a twin multiple Select box control to select items.
|
PickList are provided by Option
objects like for a Select.
PickList pickList = new PickList("languages"); pickList.setHeaderLabel("Languages", "Selected"); pickList.add(new Option("001", "Java")); pickList.add(new Option("002", "Ruby")); pickList.add(new Option("003", "Perl")); pickList.addSelectedValue("001");The selected values can be retrieved from
getSelectedValues().
Set selectedValues = pickList.getSelectedValues();
for (Iterator i = selectedValues.iterator(); i.hasNext();){
String value = (String) i.next();
...
}
| Field Summary | |
|---|---|
protected int |
height
The list height. |
static String |
HTML_IMPORTS
The Palette.js imports statement. |
protected List |
optionList
The Option list. |
protected String |
selectedLabel
The label text for the selected list. |
protected List |
selectedValues
The selected values. |
protected int |
size
The component size (width) in pixels. |
protected String |
unselectedLabel
The label text for the unselected list. |
protected static String |
VALIDATE_PICKLIST_FUNCTION
The field validation JavaScript function template. |
| Fields inherited from class net.sf.click.control.Field |
|---|
disabled, error, focus, form, help, label, readonly, required, tabindex, title, validate, value |
| Fields inherited from class net.sf.click.control.AbstractControl |
|---|
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles |
| Fields inherited from interface net.sf.click.Control |
|---|
CONTROL_MESSAGES |
| Constructor Summary | |
|---|---|
PickList()
Create a PickList with no name defined. |
|
PickList(String name)
Create a PickList field with the given name. |
|
PickList(String name,
String label)
Create a PickList field with the given name and label. |
|
| Method Summary | |
|---|---|
void |
add(Option option)
Add the given Option to the PickList. |
void |
addAll(Collection options)
Add the given Option collection to the PickList. |
void |
addAll(Collection objects,
String value,
String label)
Add the given collection of objects to the PickList, creating new Option instances based on the object properties specified by value and label. |
void |
addAll(Map options)
Add the given Map of option values and labels to the PickList. |
void |
addAll(String[] options)
Add the given array of string options to the PickList. |
void |
addSelectedValue(String value)
Add the selected value. |
void |
bindRequestValue()
Bind the request submission, setting the selectedValues
property if defined in the request. |
int |
getHeight()
Return the list height. |
String |
getHtmlImports()
Return the HTML head import statements for the JavaScript (click/extras-control.js) file. |
List |
getOptionList()
Return the Option list. |
List |
getSelectedValues()
Return selected values. |
int |
getSize()
Return the component size (width) in pixels. |
String |
getValidationJavaScript()
Return the field JavaScript client side validation function. |
void |
onDeploy(ServletContext servletContext)
Deploy the extras-control.js file to the click web directory when the application is initialized. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the PickList. |
protected void |
renderTemplate(HtmlStringBuffer buffer,
Map model)
Render a Velocity template for the given data model. |
void |
setHeaderLabel(String unselectedLabel,
String selectedLabel)
Set the header label text for the selected list and the unselected list. |
void |
setHeight(int height)
Set the list height. |
void |
setSelectedValues(Collection objects,
String value)
The PickList selected values will be derived from the given collection of objects, based on the object properties specified by value. |
void |
setSize(int size)
Set the component size. |
String |
toString()
Return a HTML rendered PickList string. |
void |
validate()
Validate the PickList request submission. |
| Methods inherited from class net.sf.click.control.Field |
|---|
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isValid, onInit, onProcess, setDisabled, setError, setErrorMessage, setErrorMessage, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setListener, setReadonly, setRequired, setTabIndex, setTextAlign, setTitle, setValidate, setValue, setValueObject, setWidth |
| Methods inherited from class net.sf.click.control.AbstractControl |
|---|
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getControlSizeEst, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, getTag, hasAttribute, hasAttributes, hasStyles, onDestroy, onRender, registerActionEvent, removeStyleClass, renderTagBegin, renderTagEnd, setActionListener, setAttribute, setId, setName, setParent, setStyle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String HTML_IMPORTS
protected static final String VALIDATE_PICKLIST_FUNCTION
protected int height
protected List optionList
protected String selectedLabel
protected List selectedValues
protected int size
protected String unselectedLabel
| Constructor Detail |
|---|
public PickList(String name,
String label)
name - the name of the fieldlabel - the label of the fieldpublic PickList(String name)
name - the name of the fieldpublic PickList()
| Method Detail |
|---|
public void add(Option option)
option - the Option value to add
IllegalArgumentException - if option is nullpublic void addAll(Collection options)
options - the collection of Option objects to add
IllegalArgumentException - if options is nullpublic void addAll(Map options)
options - the Map of option values and labels to add
IllegalArgumentException - if options is nullpublic void addAll(String[] options)
Option.value and
Option.label.
options - the array of option values to add
IllegalArgumentException - if options is null
public void addAll(Collection objects,
String value,
String label)
PickList list = new PickList("type", "Type:");
list.addAll(getCustomerService().getCustomerTypes(), "id", "name);
form.add(list);
For example given the Collection of CustomerType objects,
value "id" and label "name", the id and
name properties of each CustomerType will be retrieved. For each
CustomerType in the Collection a new Option
instance is created and its value and label is set to
the value and label retrieved from the CustomerType
instance.
objects - the collection of objects to render as optionsvalue - the name of the object property to render as the Option valuelabel - the name of the object property to render as the Option label
IllegalArgumentException - if options, value or label parameter is null
public void setHeaderLabel(String unselectedLabel,
String selectedLabel)
unselectedLabel - the label text for the unselected listselectedLabel - the label text for the selected listpublic List getOptionList()
public int getHeight()
public void setHeight(int height)
height - the list heightpublic String getHtmlImports()
getHtmlImports in interface ControlgetHtmlImports in class AbstractControlControl.getHtmlImports()
public void setSelectedValues(Collection objects,
String value)
PickList list = new PickList("type", "Type:");
// Fill the PickList with product types
list.addAll(getCustomerService().getProductTypes(), "id", "name");
// Set the PickList selected values to the list of products of the
// current customer
list.setSelectedValues(getCustomer().getProductTypes(), "id");
form.add(list);
For example given the Collection of ProductType objects and the
value "id", the id property of each ProductType will
be retrieved and added to the PickList selectedValues.
objects - the collection of objects to render selected valuesvalue - the name of the object property to render as the Option value
IllegalArgumentException - if options or value parameter is nullpublic void addSelectedValue(String value)
value - the selected value
IllegalArgumentException - if the value is nullpublic List getSelectedValues()
public void setSize(int size)
size - the component sizepublic int getSize()
public String getValidationJavaScript()
getValidationJavaScript in class Fieldpublic void bindRequestValue()
selectedValues
property if defined in the request.
bindRequestValue in class Fieldpublic void onDeploy(ServletContext servletContext)
onDeploy in interface ControlonDeploy in class AbstractControlservletContext - the servlet contextControl.onDeploy(ServletContext)public void validate()
Error message bundle key names include:net.sf.click.control.MessageProperties
- field-required-error
validate in class Fieldpublic void render(HtmlStringBuffer buffer)
render in interface Controlrender in class AbstractControlbuffer - the specified buffer to render the control's output totoString()public String toString()
toString in class AbstractControl
protected void renderTemplate(HtmlStringBuffer buffer,
Map model)
buffer - the specified buffer to render the template output tomodel - the model data to merge with the template
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||