org.apache.click.extras.control
Class CountrySelect

java.lang.Object
  extended by org.apache.click.control.AbstractControl
      extended by org.apache.click.control.Field
          extended by org.apache.click.control.Select
              extended by org.apache.click.extras.control.CountrySelect
All Implemented Interfaces:
Serializable, Control, Stateful

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 generated 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 practical for registration forms.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.click.control.Select
dataProvider, defaultOption, multiple, optionList, selectedValues, size, VALIDATE_SELECT_FUNCTION
 
Fields inherited from class org.apache.click.control.Field
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value
 
Fields inherited from class org.apache.click.control.AbstractControl
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles
 
Fields inherited from interface org.apache.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
 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.
 void validate()
          Validate the Select request submission.
 
Methods inherited from class org.apache.click.control.Select
add, add, add, add, addAll, addAll, addAll, addAll, bindRequestValue, getControlSizeEst, getDataProvider, getDefaultOption, getDefaultOptionValue, getMultipleValues, getOptionList, getSelectedValues, getSize, getState, getTag, getValidationJavaScript, isMultiple, onRender, setDataProvider, setDefaultOption, setInitialValue, setMultiple, setMultipleValues, setOptionList, setSelectedValues, setSize, setState
 
Methods inherited from class org.apache.click.control.Field
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, onProcess, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValue, setValueObject, setWidth
 
Methods inherited from class org.apache.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onDestroy, onInit, removeBehavior, removeStyleClass, 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()

validate

public void validate()
Validate the Select request submission.

Overrides:
validate in class Select
See Also:
Select.validate()

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.

Specified by:
render in interface Control
Overrides:
render in class Select
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.