1
22
23 package com.liferay.util.bridges.jsf.common;
24
25 import com.liferay.portal.kernel.language.LanguageUtil;
26 import com.liferay.portal.kernel.log.Log;
27 import com.liferay.portal.kernel.log.LogFactoryUtil;
28
29 import java.util.Collection;
30 import java.util.Locale;
31 import java.util.Map;
32 import java.util.Set;
33
34 import javax.faces.context.FacesContext;
35
36
46 public class LanguageManagedBean implements Map {
47
48 public LanguageManagedBean() {
49
50
52 FacesContext facesContext = FacesContext.getCurrentInstance();
53
54 _companyId = JSFPortletUtil.getCompanyId(facesContext);
55
56 if (_companyId == 0) {
57 _log.error("Unable to determine company id from facesContext");
58 }
59 }
60
61 public void clear() {
62 throw new UnsupportedOperationException();
63 }
64
65 public boolean containsKey(Object key) {
66 throw new UnsupportedOperationException();
67 }
68
69 public boolean containsValue(Object value) {
70 throw new UnsupportedOperationException();
71 }
72
73 public boolean isEmpty() {
74 throw new UnsupportedOperationException();
75 }
76
77 public Set entrySet() {
78 throw new UnsupportedOperationException();
79 }
80
81 public Object get(Object key) {
82 Object value = null;
83
84 if (key != null) {
85 FacesContext facesContext = FacesContext.getCurrentInstance();
86
87 Locale locale = facesContext.getViewRoot().getLocale();
88
89 if (locale == null) {
90 locale = facesContext.getApplication().getDefaultLocale();
91 }
92
93 value = LanguageUtil.get(_companyId, locale, key.toString());
94
95 if (_log.isDebugEnabled()) {
96 _log.debug(
97 "{companyId=" + _companyId + ", locale=" + locale +
98 ", key=" + key + ", value=" + value);
99 }
100 }
101
102 return value;
103 }
104
105 public Set keySet() {
106 throw new UnsupportedOperationException();
107 }
108
109 public Object put(Object key, Object value) {
110 throw new UnsupportedOperationException();
111 }
112
113 public void putAll(Map map) {
114 throw new UnsupportedOperationException();
115 }
116
117 public Object remove(Object key) {
118 throw new UnsupportedOperationException();
119 }
120
121 public int size() {
122 throw new UnsupportedOperationException();
123 }
124
125 public Collection values() {
126 throw new UnsupportedOperationException();
127 }
128
129 private static Log _log = LogFactoryUtil.getLog(LanguageManagedBean.class);
130
131 private long _companyId = 0;
132
133 }