1 14 15 package com.sun.facelets.el; 16 17 import java.io.Externalizable ; 18 import java.io.IOException ; 19 import java.io.ObjectInput ; 20 import java.io.ObjectOutput ; 21 22 import javax.el.ELContext; 23 import javax.el.ELException; 24 import javax.el.PropertyNotWritableException; 25 import javax.el.ValueExpression; 26 import javax.faces.context.FacesContext; 27 import javax.faces.el.EvaluationException; 28 import javax.faces.el.PropertyNotFoundException; 29 import javax.faces.el.ValueBinding; 30 31 38 public final class LegacyValueBinding extends ValueBinding implements Externalizable { 39 40 private static final long serialVersionUID = 1L; 41 42 private ValueExpression delegate; 43 44 public LegacyValueBinding() { 45 super(); 46 } 47 48 public LegacyValueBinding(ValueExpression ve) { 49 this.delegate = ve; 50 } 51 52 public Object getValue(FacesContext context) throws EvaluationException, 53 PropertyNotFoundException { 54 ELContext ctx = ELAdaptor.getELContext(context); 55 try { 56 return this.delegate.getValue(ctx); 57 } catch (javax.el.PropertyNotFoundException e) { 58 throw new PropertyNotFoundException(e.getMessage(), e.getCause()); 59 } catch (ELException e) { 60 throw new EvaluationException(e.getMessage(), e.getCause()); 61 } 62 } 63 64 public void setValue(FacesContext context, Object value) 65 throws EvaluationException, PropertyNotFoundException { 66 ELContext ctx = ELAdaptor.getELContext(context); 67 try { 68 this.delegate.setValue(ctx, value); 69 } catch (PropertyNotWritableException e) { 70 throw new PropertyNotFoundException(e.getMessage(), e.getCause()); 71 } catch (javax.el.PropertyNotFoundException e) { 72 throw new PropertyNotFoundException(e.getMessage(), e.getCause()); 73 } catch (ELException e) { 74 throw new EvaluationException(e.getMessage(), e.getCause()); 75 } 76 } 77 78 public boolean isReadOnly(FacesContext context) throws EvaluationException, 79 PropertyNotFoundException { 80 ELContext ctx = ELAdaptor.getELContext(context); 81 try { 82 return this.delegate.isReadOnly(ctx); 83 } catch (javax.el.PropertyNotFoundException e) { 84 throw new PropertyNotFoundException(e.getMessage(), e.getCause()); 85 } catch (ELException e) { 86 throw new EvaluationException(e.getMessage(), e.getCause()); 87 } 88 } 89 90 public Class getType(FacesContext context) throws EvaluationException, 91 PropertyNotFoundException { 92 ELContext ctx = ELAdaptor.getELContext(context); 93 try { 94 return this.delegate.getType(ctx); 95 } catch (javax.el.PropertyNotFoundException e) { 96 throw new PropertyNotFoundException(e.getMessage(), e.getCause()); 97 } catch (ELException e) { 98 throw new EvaluationException(e.getMessage(), e.getCause()); 99 } 100 } 101 102 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 103 this.delegate = (ValueExpression) in.readObject(); 104 } 105 106 public void writeExternal(ObjectOutput out) throws IOException { 107 out.writeObject(this.delegate); 108 } 109 110 public String getExpressionString() { 111 return this.delegate.getExpressionString(); 112 } 113 } 114 | Popular Tags |