View Javadoc

1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * 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, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.springframework.extensions.webscripts.ui.common;
20  
21  import javax.faces.component.StateHolder;
22  import javax.faces.context.FacesContext;
23  import javax.faces.el.MethodBinding;
24  
25  public class ConstantMethodBinding extends MethodBinding implements StateHolder
26  {
27     private String outcome = null;
28     private boolean transientFlag = false;
29  
30     public ConstantMethodBinding()
31     {
32     }
33  
34     public ConstantMethodBinding(String yourOutcome)
35     {
36        outcome = yourOutcome;
37     }
38  
39     public Object invoke(FacesContext context, Object params[])
40     {
41        return outcome;
42     }
43  
44     public Class getType(FacesContext context)
45     {
46        return String.class;
47     }
48  
49     public Object saveState(FacesContext context)
50     {
51        return outcome;
52     }
53  
54     public void restoreState(FacesContext context, Object state)
55     {
56        outcome = (String) state;
57     }
58  
59     public boolean isTransient()
60     {
61        return (this.transientFlag);
62     }
63  
64     public void setTransient(boolean transientFlag)
65     {
66        this.transientFlag = transientFlag;
67     }
68  }