1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.myfaces.el;
17
18 import javax.faces.component.StateHolder;
19 import javax.faces.context.FacesContext;
20 import javax.faces.el.EvaluationException;
21 import javax.faces.el.MethodBinding;
22 import javax.faces.el.MethodNotFoundException;
23
24 /***
25 * Convenient method binding that does nothing other than returning a fixed outcome String when invoked.
26 *
27 * @author Manfred Geiler
28 */
29 public class SimpleActionMethodBinding
30 extends MethodBinding
31 implements StateHolder
32 {
33 private String _outcome;
34
35 public SimpleActionMethodBinding(String outcome)
36 {
37 _outcome = outcome;
38 }
39
40 public Object invoke(FacesContext facescontext, Object aobj[]) throws EvaluationException, MethodNotFoundException
41 {
42 return _outcome;
43 }
44
45 public Class getType(FacesContext facescontext) throws MethodNotFoundException
46 {
47 return String.class;
48 }
49
50
51
52
53 private boolean _transient = false;
54
55 /***
56 * Empty constructor, so that new instances can be created when restoring state.
57 */
58 public SimpleActionMethodBinding()
59 {
60 _outcome = null;
61 }
62
63 public Object saveState(FacesContext facescontext)
64 {
65 return _outcome;
66 }
67
68 public void restoreState(FacesContext facescontext, Object obj)
69 {
70 _outcome = (String)obj;
71 }
72
73 public boolean isTransient()
74 {
75 return _transient;
76 }
77
78 public void setTransient(boolean flag)
79 {
80 _transient = flag;
81 }
82
83 public String toString()
84 {
85 return _outcome;
86 }
87 }