myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johan Gorter (JIRA)" <>
Subject [jira] Created: (TOMAHAWK-227) Possibility to select nothing
Date Mon, 03 Apr 2006 07:44:43 GMT
Possibility to select nothing

         Key: TOMAHAWK-227
     Project: MyFaces Tomahawk
        Type: Improvement

  Components: selectOneRadio / radio  
    Reporter: Johan Gorter

The UISelectOne descendants, especially the HtmlSelectOneMenu is missing a powerful option.
They cannot be used to select nothing/null. 

I am using the selectCountry component to select an optional nationality of a person. This
field is not required, so it should be able to display the empty option,  resolving to null
instead of a country code. I am using my own descendant of SelectOneCountry as displayed below.
I think however that all users of tomahawk components would greatly benefit if the empty option
can be turned on in a super component, like UISelectOne. This is also very useful with required="true".
The user is then forced to select something, otherwise a validation error occurs.

Hope you agree with this usefullness.


Johan Gorter

public class SelectOneOrNoCountry extends SelectOneCountry {
	private static final String NULL_MASK="@@NULL@@";
	private static SelectItem NOCOUNTRY=new SelectItem();
	static {
		NOCOUNTRY.setLabel(" - ");
	protected List getCountriesChoicesAsSelectItemList() {
		List result = super.getCountriesChoicesAsSelectItemList();
		result.add(0, NOCOUNTRY);
		return result;
	protected Object getConvertedValue(FacesContext context, Object submittedValue) {
		if (NULL_MASK.equals(submittedValue)) {
			return null;
		return super.getConvertedValue(context, submittedValue);


This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message