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.context.FacesContext;
25 import javax.faces.el.EvaluationException;
26 import javax.faces.el.MethodBinding;
27 import javax.faces.el.MethodNotFoundException;
28
29
30
31
32
33
34
35
36
37 class _MethodExpressionToMethodBinding extends MethodBinding implements StateHolder
38 {
39
40 private MethodExpression methodExpression;
41
42 private boolean isTransient = false;
43
44 public _MethodExpressionToMethodBinding()
45 {
46 methodExpression = null;
47 }
48
49
50 public _MethodExpressionToMethodBinding(MethodExpression methodExpression)
51 {
52 this.methodExpression = methodExpression;
53 }
54
55 @Override
56 public String getExpressionString()
57 {
58 return methodExpression.getExpressionString();
59 }
60
61 @Override
62 public Class getType(FacesContext facesContext) throws MethodNotFoundException
63 {
64
65 try
66 {
67 return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType();
68 }
69 catch (javax.el.MethodNotFoundException e)
70 {
71 throw new javax.faces.el.MethodNotFoundException(e);
72 }
73 catch (ELException e)
74 {
75 throw new EvaluationException(e);
76 }
77 }
78
79 @Override
80 public Object invoke(FacesContext facesContext, Object[] params) throws EvaluationException,
81 MethodNotFoundException
82 {
83
84 try
85 {
86 return methodExpression.invoke(facesContext.getELContext(), params);
87 }
88 catch (javax.el.MethodNotFoundException e)
89 {
90 throw new javax.faces.el.MethodNotFoundException(e);
91 }
92 catch (ELException e)
93 {
94 throw new EvaluationException(e);
95 }
96 }
97
98
99
100 public void restoreState(FacesContext context, Object state)
101 {
102 if (state != null)
103 {
104 methodExpression = (MethodExpression) state;
105 }
106 }
107
108 public Object saveState(FacesContext context)
109 {
110 if (!isTransient)
111 {
112 return methodExpression;
113 }
114 return null;
115 }
116
117 public void setTransient(boolean newTransientValue)
118 {
119 isTransient = newTransientValue;
120 }
121
122 public boolean isTransient()
123 {
124 return isTransient;
125 }
126
127 }