001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 018 * 019 * $Id: UIDirectorySelectItem.java 29556 2008-01-23 00:59:39Z jcarsique $ 020 */ 021 022package org.nuxeo.ecm.platform.ui.web.directory; 023 024import javax.faces.model.SelectItem; 025 026import org.nuxeo.ecm.platform.ui.web.component.UISelectItem; 027 028/** 029 * Component that deals with a select item from a directory. 030 * 031 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 032 */ 033public class UIDirectorySelectItem extends UISelectItem { 034 035 public static final String COMPONENT_TYPE = UIDirectorySelectItem.class.getName(); 036 037 enum PropertyKeys { 038 directoryName 039 } 040 041 // setters & getters 042 043 public String getDirectoryName() { 044 return (String) getStateHelper().eval(PropertyKeys.directoryName); 045 } 046 047 public void setDirectoryName(String directoryName) { 048 getStateHelper().put(PropertyKeys.directoryName, directoryName); 049 } 050 051 @Override 052 public Object getValue() { 053 Object value = super.getValue(); 054 return new DirectorySelectItemFactory() { 055 056 @Override 057 protected String getVar() { 058 return UIDirectorySelectItem.this.getVar(); 059 } 060 061 @Override 062 protected SelectItem createSelectItem() { 063 return UIDirectorySelectItem.this.createSelectItem(); 064 } 065 066 @Override 067 protected String getDirectoryName() { 068 return UIDirectorySelectItem.this.getDirectoryName(); 069 } 070 }.createSelectItem(value); 071 } 072 073}