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 | 0 | private boolean isTransient = false; |
46 | |
|
47 | 0 | public _MethodExpressionToMethodBinding() { |
48 | 0 | methodExpression = null; |
49 | 0 | } |
50 | |
|
51 | |
|
52 | 0 | public _MethodExpressionToMethodBinding(MethodExpression methodExpression) { |
53 | 0 | this.methodExpression = methodExpression; |
54 | 0 | } |
55 | |
|
56 | |
@Override |
57 | |
public String getExpressionString() |
58 | |
{ |
59 | 0 | return methodExpression.getExpressionString(); |
60 | |
} |
61 | |
|
62 | |
public Class getType(FacesContext facesContext) |
63 | |
throws MethodNotFoundException { |
64 | |
|
65 | |
try { |
66 | 0 | return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType(); |
67 | 0 | } catch (javax.el.MethodNotFoundException e) { |
68 | 0 | throw new javax.faces.el.MethodNotFoundException(e); |
69 | 0 | } catch (ELException e) { |
70 | 0 | throw new EvaluationException(e); |
71 | |
} |
72 | |
} |
73 | |
|
74 | |
public Object invoke(FacesContext facesContext, Object[] params) |
75 | |
throws EvaluationException, MethodNotFoundException { |
76 | |
|
77 | |
try { |
78 | 0 | return methodExpression.invoke(facesContext.getELContext(), params); |
79 | 0 | } catch (javax.el.MethodNotFoundException e) { |
80 | 0 | throw new javax.faces.el.MethodNotFoundException(e); |
81 | 0 | } catch (ELException e) { |
82 | 0 | throw new EvaluationException(e); |
83 | |
} |
84 | |
} |
85 | |
|
86 | |
|
87 | |
|
88 | |
public void restoreState(FacesContext context, Object state) { |
89 | 0 | if(state != null) |
90 | 0 | methodExpression = (MethodExpression)state; |
91 | 0 | } |
92 | |
|
93 | |
public Object saveState(FacesContext context) { |
94 | 0 | if(!isTransient) |
95 | 0 | return methodExpression; |
96 | 0 | return null; |
97 | |
} |
98 | |
|
99 | |
public void setTransient(boolean newTransientValue) { |
100 | 0 | isTransient = newTransientValue; |
101 | 0 | } |
102 | |
|
103 | |
public boolean isTransient() { |
104 | 0 | return isTransient; |
105 | |
} |
106 | |
|
107 | |
} |