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 * Nuxeo - initial API and implementation 018 * 019 * $Id: DirectoryEntryOutputComponent.java 29914 2008-02-06 14:46:40Z atchertchian $ 020 */ 021 022package org.nuxeo.ecm.platform.ui.web.directory; 023 024import javax.faces.context.FacesContext; 025import javax.faces.el.ValueBinding; 026 027import org.apache.commons.logging.Log; 028import org.apache.commons.logging.LogFactory; 029 030/** 031 * Component to display a directory entry. 032 * 033 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 034 */ 035public class DirectoryEntryOutputComponent extends DirectoryAwareComponent { 036 037 private static final Log log = LogFactory.getLog(DirectoryEntryOutputComponent.class); 038 039 public static final String COMPONENT_TYPE = "nxdirectory.DirectoryEntryOutput"; 040 041 public static final String COMPONENT_FAMILY = "nxdirectory.DirectoryEntryOutput"; 042 043 /** 044 * @deprecated standard value attribute should be used instead 045 */ 046 @Deprecated 047 protected String entryId; 048 049 protected String keySeparator; 050 051 /** 052 * @deprecated never used 053 */ 054 @Deprecated 055 protected String display; 056 057 public DirectoryEntryOutputComponent() { 058 setRendererType(COMPONENT_TYPE); 059 } 060 061 @Override 062 public String getFamily() { 063 return COMPONENT_FAMILY; 064 } 065 066 /** 067 * @deprecated use standard {@link #getValue()} instead 068 */ 069 @Deprecated 070 public String getEntryId() { 071 ValueBinding vb = getValueBinding("entryId"); 072 if (vb != null) { 073 log.warn("\"entryId\" attribute is deprecated on " + "DirectoryEntryOutputComponent, use \"value\" instead"); 074 return (String) vb.getValue(getFacesContext()); 075 } else { 076 return entryId; 077 } 078 } 079 080 /** 081 * @deprecated use standard {@link #setValue(Object)} instead 082 */ 083 @Deprecated 084 public void setEntryId(String entryId) { 085 log.warn("\"entryId\" attribute is deprecated on " + "DirectoryEntryOutputComponent, use \"value\" instead"); 086 setValue(entryId); 087 } 088 089 /** 090 * @deprecated use {@link #getLocalize()} instead 091 */ 092 @Deprecated 093 public Boolean getTranslate() { 094 return localize; 095 } 096 097 /** 098 * @deprecated use {@link #setLocalize(Boolean)} instead 099 */ 100 @Deprecated 101 public void setTranslate(Boolean translate) { 102 log.warn("\"translate\" attribute is deprecated on " 103 + "DirectoryEntryOutputComponent, use \"localize\" instead"); 104 localize = translate; 105 } 106 107 public String getKeySeparator() { 108 if (keySeparator != null) { 109 return keySeparator; 110 } 111 return getStringValue("keySeparator", null); 112 } 113 114 public void setKeySeparator(String keySeparator) { 115 this.keySeparator = keySeparator; 116 } 117 118 /** 119 * @deprecated never used 120 */ 121 @Override 122 @Deprecated 123 public String getDisplay() { 124 return display; 125 } 126 127 /** 128 * @deprecated never used 129 */ 130 @Override 131 @Deprecated 132 public void setDisplay(String display) { 133 this.display = display; 134 } 135 136 @Override 137 public Object saveState(FacesContext context) { 138 Object[] values = new Object[4]; 139 values[0] = super.saveState(context); 140 values[1] = entryId; 141 values[2] = keySeparator; 142 values[3] = display; 143 return values; 144 } 145 146 @Override 147 public void restoreState(FacesContext context, Object state) { 148 Object[] values = (Object[]) state; 149 super.restoreState(context, values[0]); 150 entryId = (String) values[1]; 151 keySeparator = (String) values[2]; 152 display = (String) values[3]; 153 } 154}