1 14 15 package com.sun.facelets.el; 16 17 import java.util.Map ; 18 19 import javax.el.ELContext; 20 import javax.el.ExpressionFactory; 21 import javax.el.ValueExpression; 22 import javax.faces.component.UIComponent; 23 import javax.faces.context.FacesContext; 24 25 import com.sun.facelets.util.FacesAPI; 26 27 33 public final class ELAdaptor { 34 35 private static final boolean ELSUPPORT = (FacesAPI.getVersion() >= 12); 36 37 private final static String LEGACY_ELCONTEXT_KEY = "com.sun.facelets.legacy.ELCONTEXT"; 38 39 public ELAdaptor() { 40 super(); 41 } 42 43 public final static ELContext getELContext(FacesContext faces) { 44 if (ELSUPPORT) { 45 return faces.getELContext(); 46 } else { 47 Map request = faces.getExternalContext().getRequestMap(); 48 Object ctx = request.get(LEGACY_ELCONTEXT_KEY); 49 if (!(ctx instanceof LegacyELContext) 50 || (((LegacyELContext) ctx).getFacesContext() != faces)) { 51 ctx = new LegacyELContext(faces); 52 request.put(LEGACY_ELCONTEXT_KEY, ctx); 53 } 54 return (ELContext) ctx; 55 } 56 } 57 58 public final static void setExpression(UIComponent c, String name, 59 ValueExpression ve) { 60 if (FacesAPI.getComponentVersion(c) >= 12) { 61 c.setValueExpression(name, ve); 62 } else { 63 c.setValueBinding(name, new LegacyValueBinding(ve)); 64 } 65 } 66 67 } 68 | Popular Tags |