001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 * $Id: DirectoryEntryOutputComponent.java 29914 2008-02-06 14:46:40Z atchertchian $ 018 */ 019 020package org.nuxeo.ecm.platform.ui.web.directory; 021 022import javax.faces.context.FacesContext; 023import javax.faces.el.ValueBinding; 024 025import org.apache.commons.logging.Log; 026import org.apache.commons.logging.LogFactory; 027 028/** 029 * Component to display a directory entry. 030 * 031 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 032 */ 033public class DirectoryEntryOutputComponent extends DirectoryAwareComponent { 034 035 private static final Log log = LogFactory.getLog(DirectoryEntryOutputComponent.class); 036 037 public static final String COMPONENT_TYPE = "nxdirectory.DirectoryEntryOutput"; 038 039 public static final String COMPONENT_FAMILY = "nxdirectory.DirectoryEntryOutput"; 040 041 /** 042 * @deprecated standard value attribute should be used instead 043 */ 044 @Deprecated 045 protected String entryId; 046 047 protected String keySeparator; 048 049 /** 050 * @deprecated never used 051 */ 052 @Deprecated 053 protected String display; 054 055 public DirectoryEntryOutputComponent() { 056 setRendererType(COMPONENT_TYPE); 057 } 058 059 @Override 060 public String getFamily() { 061 return COMPONENT_FAMILY; 062 } 063 064 /** 065 * @deprecated use standard {@link #getValue()} instead 066 */ 067 @Deprecated 068 public String getEntryId() { 069 ValueBinding vb = getValueBinding("entryId"); 070 if (vb != null) { 071 log.warn("\"entryId\" attribute is deprecated on " + "DirectoryEntryOutputComponent, use \"value\" instead"); 072 return (String) vb.getValue(getFacesContext()); 073 } else { 074 return entryId; 075 } 076 } 077 078 /** 079 * @deprecated use standard {@link #setValue(Object)} instead 080 */ 081 @Deprecated 082 public void setEntryId(String entryId) { 083 log.warn("\"entryId\" attribute is deprecated on " + "DirectoryEntryOutputComponent, use \"value\" instead"); 084 setValue(entryId); 085 } 086 087 /** 088 * @deprecated use {@link #getLocalize()} instead 089 */ 090 @Deprecated 091 public Boolean getTranslate() { 092 return localize; 093 } 094 095 /** 096 * @deprecated use {@link #setLocalize(Boolean)} instead 097 */ 098 @Deprecated 099 public void setTranslate(Boolean translate) { 100 log.warn("\"translate\" attribute is deprecated on " 101 + "DirectoryEntryOutputComponent, use \"localize\" instead"); 102 localize = translate; 103 } 104 105 public String getKeySeparator() { 106 if (keySeparator != null) { 107 return keySeparator; 108 } 109 return getStringValue("keySeparator", null); 110 } 111 112 public void setKeySeparator(String keySeparator) { 113 this.keySeparator = keySeparator; 114 } 115 116 /** 117 * @deprecated never used 118 */ 119 @Override 120 @Deprecated 121 public String getDisplay() { 122 return display; 123 } 124 125 /** 126 * @deprecated never used 127 */ 128 @Override 129 @Deprecated 130 public void setDisplay(String display) { 131 this.display = display; 132 } 133 134 @Override 135 public Object saveState(FacesContext context) { 136 Object[] values = new Object[4]; 137 values[0] = super.saveState(context); 138 values[1] = entryId; 139 values[2] = keySeparator; 140 values[3] = display; 141 return values; 142 } 143 144 @Override 145 public void restoreState(FacesContext context, Object state) { 146 Object[] values = (Object[]) state; 147 super.restoreState(context, values[0]); 148 entryId = (String) values[1]; 149 keySeparator = (String) values[2]; 150 display = (String) values[3]; 151 } 152}