Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SimpleActionMethodBinding |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.apache.myfaces.shared.el; | |
20 | ||
21 | import javax.faces.component.StateHolder; | |
22 | import javax.faces.context.FacesContext; | |
23 | import javax.faces.el.EvaluationException; | |
24 | import javax.faces.el.MethodBinding; | |
25 | import javax.faces.el.MethodNotFoundException; | |
26 | ||
27 | /** | |
28 | * Convenient method binding that does nothing other than returning a fixed outcome String when invoked. | |
29 | */ | |
30 | public class SimpleActionMethodBinding | |
31 | extends MethodBinding | |
32 | implements StateHolder | |
33 | { | |
34 | private String _outcome; | |
35 | ||
36 | public SimpleActionMethodBinding(String outcome) | |
37 | 0 | { |
38 | 0 | _outcome = outcome; |
39 | 0 | } |
40 | ||
41 | public Object invoke(FacesContext facescontext, Object aobj[]) throws EvaluationException, MethodNotFoundException | |
42 | { | |
43 | 0 | return _outcome; |
44 | } | |
45 | ||
46 | public Class getType(FacesContext facescontext) throws MethodNotFoundException | |
47 | { | |
48 | 0 | return String.class; |
49 | } | |
50 | ||
51 | ||
52 | //~ StateHolder support ---------------------------------------------------------------------------- | |
53 | ||
54 | 0 | private boolean _transient = false; |
55 | ||
56 | /** | |
57 | * Empty constructor, so that new instances can be created when restoring state. | |
58 | */ | |
59 | public SimpleActionMethodBinding() | |
60 | 0 | { |
61 | 0 | _outcome = null; |
62 | 0 | } |
63 | ||
64 | public Object saveState(FacesContext facescontext) | |
65 | { | |
66 | 0 | return _outcome; |
67 | } | |
68 | ||
69 | public void restoreState(FacesContext facescontext, Object obj) | |
70 | { | |
71 | 0 | _outcome = (String)obj; |
72 | 0 | } |
73 | ||
74 | public boolean isTransient() | |
75 | { | |
76 | 0 | return _transient; |
77 | } | |
78 | ||
79 | public void setTransient(boolean flag) | |
80 | { | |
81 | 0 | _transient = flag; |
82 | 0 | } |
83 | ||
84 | public String toString() | |
85 | { | |
86 | 0 | return _outcome; |
87 | } | |
88 | } |