001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.util.bridges.jsf.common;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.util.StringPool;
019    
020    import java.util.ArrayList;
021    import java.util.Locale;
022    
023    import javax.faces.context.FacesContext;
024    import javax.faces.model.SelectItem;
025    
026    /**
027     * <p>
028     * This class provides a convenient way of building lists of JSF SelectItem
029     * objects, and convenience method for operating against them.
030     * </p>
031     *
032     * @author Neil Griffin
033     */
034    public class SelectItemList extends ArrayList<SelectItem> {
035    
036            public void prependEmptySelectItem(FacesContext facesContext) {
037                    Locale locale = facesContext.getExternalContext().getRequestLocale();
038    
039                    Object value = StringPool.BLANK;
040                    String label = LanguageUtil.get(locale, "select");
041    
042                    add(0, new SelectItem(value, label));
043            }
044    
045    }