net.sf.click.extras.control
Class CountrySelect

java.lang.Object
  extended bynet.sf.click.control.AbstractControl
      extended bynet.sf.click.control.Field
          extended bynet.sf.click.control.Select
              extended bynet.sf.click.extras.control.CountrySelect
All Implemented Interfaces:
Control, Serializable

public class CountrySelect
extends Select

Provides a Country Select control:   <select></select>.

Select
The CountrySelect Control that is fully i18n aware. The country list is not hardcoded but genereated by the JDK, i.e. there's an Option for each country that has a supported Locale from the side of the JDK.

Note: Newer versions of the JDK seems to support more Locales.

Obs.: Especially practial for registration forms.

Author:
Ahmed Mohombe
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.click.control.Select
multiple, optionList, selectedValues, size, VALIDATE_SELECT_FUNCTION
 
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
CountrySelect()
          Create a CountrySelect field with no name defined.
CountrySelect(String name)
          Create a CountrySelect field with the given name.
CountrySelect(String name, boolean required)
          Create a CountrySelect field with the given name and required status.
CountrySelect(String name, String label)
          Create a CountrySelect field with the given name and label.
CountrySelect(String name, String label, boolean required)
          Create a CountrySelect field with the given name, label and required status.
CountrySelect(String name, String label, Locale locale)
          Create a CountrySelect field with the given name, label and locale.
 
Method Summary
 void bindRequestValue()
          Bind the request value to the control.
 Locale getLocale()
          Return the locale for this control.
protected  void loadOptionList()
          Load the Country Select options if not defined, using all the available countries.
 void render(HtmlStringBuffer buffer)
          Render the HTML representation of the QuerySelect.
 void setLocale(Locale locale)
          Set the locale of this control to something else than the Context locale.
 
Methods inherited from class net.sf.click.control.Select
add, add, add, addAll, addAll, addAll, addAll, getControlSizeEst, getMultipleValues, getOptionList, getSelectedValues, getSize, getTag, getValidationJavaScript, isMultiple, setInitialValue, setMultiple, setMultipleValues, setOptionList, setSelectedValues, setSize, validate
 
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, setParent, setReadonly, setRequired, setTabIndex, setTextAlign, setTitle, setValidate, setValue, setValueObject, setWidth
 
Methods inherited from class net.sf.click.control.AbstractControl
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getHtmlImports, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasStyles, onDeploy, onDestroy, onRender, registerActionEvent, removeStyleClass, renderTagBegin, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CountrySelect

public CountrySelect(String name)
Create a CountrySelect field with the given name.

Parameters:
name - the name of the field

CountrySelect

public CountrySelect(String name,
                     String label)
Create a CountrySelect field with the given name and label.

Parameters:
name - the name of the field
label - the label of the field

CountrySelect

public CountrySelect(String name,
                     boolean required)
Create a CountrySelect field with the given name and required status.

Parameters:
name - the name of the field
required - the field required status

CountrySelect

public CountrySelect(String name,
                     String label,
                     boolean required)
Create a CountrySelect field with the given name, label and required status.

Parameters:
name - the name of the field
label - the label of the field
required - the field required status

CountrySelect

public CountrySelect(String name,
                     String label,
                     Locale locale)
Create a CountrySelect field with the given name, label and locale.

Parameters:
name - the name of the field
label - the label of the field
locale - the Locale of the filed

CountrySelect

public CountrySelect()
Create a CountrySelect field with no name defined.

Please note the control's name must be defined before it is valid.

Method Detail

getLocale

public Locale getLocale()
Return the locale for this control.

Returns:
the locale of this control.

setLocale

public void setLocale(Locale locale)
Set the locale of this control to something else than the Context locale.

Parameters:
locale - the locale to set for this control
See Also:
Context.getLocale()

bindRequestValue

public void bindRequestValue()
Bind the request value to the control.

See Also:
Select.bindRequestValue()

render

public void render(HtmlStringBuffer buffer)
Render the HTML representation of the QuerySelect.

If the Select option list is empty this method will load option list so that it can be rendered.

Parameters:
buffer - the specified buffer to render the control's output to
See Also:
AbstractControl.toString()

loadOptionList

protected void loadOptionList()
Load the Country Select options if not defined, using all the available countries. The option value will be the two letter uppercase ISO name of the country as the value and the localized country name as the label.