001/* 002 * (C) Copyright 2013 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 * Anahide Tchertchian 018 */ 019package org.nuxeo.ecm.platform.actions.jsf; 020 021import java.util.Locale; 022 023import javax.el.ELContext; 024import javax.el.ELResolver; 025import javax.el.FunctionMapper; 026import javax.el.VariableMapper; 027 028import com.sun.faces.facelets.el.VariableMapperWrapper; 029 030/** 031 * Wrapper around another EL context to allow override of the variable mapper for some values in context. 032 * 033 * @since 5.7.3 034 */ 035public class JSFELContext extends ELContext { 036 037 protected final ELContext originalContext; 038 039 protected final VariableMapper variableMapper; 040 041 public JSFELContext(ELContext originalContext) { 042 super(); 043 this.originalContext = originalContext; 044 this.variableMapper = new VariableMapperWrapper(originalContext.getVariableMapper()); 045 } 046 047 @Override 048 public ELResolver getELResolver() { 049 return originalContext.getELResolver(); 050 } 051 052 @Override 053 public FunctionMapper getFunctionMapper() { 054 return originalContext.getFunctionMapper(); 055 } 056 057 @Override 058 public VariableMapper getVariableMapper() { 059 return variableMapper; 060 } 061 062 @Override 063 @SuppressWarnings("rawtypes") 064 public Object getContext(Class key) { 065 return originalContext.getContext(key); 066 } 067 068 @Override 069 public Locale getLocale() { 070 return originalContext.getLocale(); 071 } 072 073 @Override 074 public boolean isPropertyResolved() { 075 return originalContext.isPropertyResolved(); 076 } 077 078 @Override 079 @SuppressWarnings("rawtypes") 080 public void putContext(Class key, Object contextObject) { 081 originalContext.putContext(key, contextObject); 082 } 083 084 @Override 085 public void setLocale(Locale locale) { 086 originalContext.setLocale(locale); 087 } 088 089 @Override 090 public void setPropertyResolved(boolean resolved) { 091 originalContext.setPropertyResolved(resolved); 092 } 093 094}