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 public DirectoryEntryOutputComponent() { 052 setRendererType(COMPONENT_TYPE); 053 } 054 055 @Override 056 public String getFamily() { 057 return COMPONENT_FAMILY; 058 } 059 060 /** 061 * @deprecated use standard {@link #getValue()} instead 062 */ 063 @Deprecated 064 public String getEntryId() { 065 ValueBinding vb = getValueBinding("entryId"); 066 if (vb != null) { 067 log.warn("\"entryId\" attribute is deprecated on " + "DirectoryEntryOutputComponent, use \"value\" instead"); 068 return (String) vb.getValue(getFacesContext()); 069 } else { 070 return entryId; 071 } 072 } 073 074 /** 075 * @deprecated use standard {@link #setValue(Object)} instead 076 */ 077 @Deprecated 078 public void setEntryId(String entryId) { 079 log.warn("\"entryId\" attribute is deprecated on " + "DirectoryEntryOutputComponent, use \"value\" instead"); 080 setValue(entryId); 081 } 082 083 /** 084 * @deprecated use {@link #getLocalize()} instead 085 */ 086 @Deprecated 087 public Boolean getTranslate() { 088 return localize; 089 } 090 091 /** 092 * @deprecated use {@link #setLocalize(Boolean)} instead 093 */ 094 @Deprecated 095 public void setTranslate(Boolean translate) { 096 log.warn("\"translate\" attribute is deprecated on " 097 + "DirectoryEntryOutputComponent, use \"localize\" instead"); 098 localize = translate; 099 } 100 101 public String getKeySeparator() { 102 if (keySeparator != null) { 103 return keySeparator; 104 } 105 return getStringValue("keySeparator", null); 106 } 107 108 public void setKeySeparator(String keySeparator) { 109 this.keySeparator = keySeparator; 110 } 111 112 @Override 113 public Object saveState(FacesContext context) { 114 Object[] values = new Object[4]; 115 values[0] = super.saveState(context); 116 values[1] = entryId; 117 values[2] = keySeparator; 118 values[3] = display; 119 return values; 120 } 121 122 @Override 123 public void restoreState(FacesContext context, Object state) { 124 Object[] values = (Object[]) state; 125 super.restoreState(context, values[0]); 126 entryId = (String) values[1]; 127 keySeparator = (String) values[2]; 128 display = (String) values[3]; 129 } 130}