1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.component;
21
22 import javax.el.ELException;
23 import javax.el.MethodExpression;
24 import javax.faces.component.StateHolder;
25 import javax.faces.context.FacesContext;
26 import javax.faces.el.EvaluationException;
27 import javax.faces.el.MethodBinding;
28 import javax.faces.el.MethodNotFoundException;
29
30
31
32
33 @Deprecated
34 public class MethodExpressionToMethodBinding extends MethodBinding implements StateHolder {
35
36 private MethodExpression methodExpression;
37
38 private boolean isTransient = false;
39
40 public MethodExpressionToMethodBinding() {
41 methodExpression = null;
42 }
43
44
45
46
47 public MethodExpressionToMethodBinding(MethodExpression methodExpression) {
48 this.methodExpression = methodExpression;
49 }
50
51 @Override
52 public String getExpressionString() {
53 return methodExpression.getExpressionString();
54 }
55
56 public Class getType(FacesContext facesContext)
57 throws MethodNotFoundException {
58
59 try {
60 return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType();
61 } catch (javax.el.MethodNotFoundException e) {
62 throw new javax.faces.el.MethodNotFoundException(e);
63 } catch (ELException e) {
64 throw new EvaluationException(e);
65 }
66 }
67
68 public Object invoke(FacesContext facesContext, Object[] params)
69 throws EvaluationException {
70
71 try {
72 return methodExpression.invoke(facesContext.getELContext(), params);
73 } catch (javax.el.MethodNotFoundException e) {
74 throw new javax.faces.el.MethodNotFoundException(e);
75 } catch (ELException e) {
76 throw new EvaluationException(e);
77 }
78 }
79
80
81 public void restoreState(FacesContext context, Object state) {
82 if (state != null) {
83 methodExpression = (MethodExpression) state;
84 }
85 }
86
87 public Object saveState(FacesContext context) {
88 if (!isTransient) {
89 return methodExpression;
90 }
91 return null;
92 }
93
94 public void setTransient(boolean newTransientValue) {
95 isTransient = newTransientValue;
96 }
97
98 public boolean isTransient() {
99 return isTransient;
100 }
101
102 }