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