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 | 4 | private boolean isTransient = false; |
43 | |
|
44 | |
public _MethodExpressionToMethodBinding() |
45 | 0 | { |
46 | 0 | methodExpression = null; |
47 | 0 | } |
48 | |
|
49 | |
|
50 | |
public _MethodExpressionToMethodBinding(MethodExpression methodExpression) |
51 | 4 | { |
52 | 4 | this.methodExpression = methodExpression; |
53 | 4 | } |
54 | |
|
55 | |
@Override |
56 | |
public String getExpressionString() |
57 | |
{ |
58 | 0 | return methodExpression.getExpressionString(); |
59 | |
} |
60 | |
|
61 | |
@Override |
62 | |
public Class getType(FacesContext facesContext) throws MethodNotFoundException |
63 | |
{ |
64 | |
|
65 | |
try |
66 | |
{ |
67 | 0 | return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType(); |
68 | |
} |
69 | 0 | catch (javax.el.MethodNotFoundException e) |
70 | |
{ |
71 | 0 | throw new javax.faces.el.MethodNotFoundException(e); |
72 | |
} |
73 | 0 | catch (ELException e) |
74 | |
{ |
75 | 0 | 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 | 0 | return methodExpression.invoke(facesContext.getELContext(), params); |
87 | |
} |
88 | 0 | catch (javax.el.MethodNotFoundException e) |
89 | |
{ |
90 | 0 | throw new javax.faces.el.MethodNotFoundException(e); |
91 | |
} |
92 | 0 | catch (ELException e) |
93 | |
{ |
94 | 0 | throw new EvaluationException(e); |
95 | |
} |
96 | |
} |
97 | |
|
98 | |
|
99 | |
|
100 | |
public void restoreState(FacesContext context, Object state) |
101 | |
{ |
102 | 0 | if (state != null) |
103 | |
{ |
104 | 0 | methodExpression = (MethodExpression) state; |
105 | |
} |
106 | 0 | } |
107 | |
|
108 | |
public Object saveState(FacesContext context) |
109 | |
{ |
110 | 0 | if (!isTransient) |
111 | |
{ |
112 | 0 | return methodExpression; |
113 | |
} |
114 | 0 | return null; |
115 | |
} |
116 | |
|
117 | |
public void setTransient(boolean newTransientValue) |
118 | |
{ |
119 | 0 | isTransient = newTransientValue; |
120 | 0 | } |
121 | |
|
122 | |
public boolean isTransient() |
123 | |
{ |
124 | 0 | return isTransient; |
125 | |
} |
126 | |
|
127 | |
} |