View Javadoc

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.trinidad.bean;
20  
21  import javax.faces.component.StateHolder;
22  import javax.faces.context.FacesContext;
23  import javax.faces.el.ValueBinding;
24  
25  import java.io.Serializable;
26  
27  // =-=AdamWiner FIXME We shouldn't have to implement Serializable
28  // on ValueBindings - FacesBeanImpl is not handling ValueExpressions
29  // around non-serializable ValueBindings
30  public class TestValueBinding extends ValueBinding implements StateHolder, 
31                                                                Serializable
32  {
33    public TestValueBinding()
34    {
35    }
36  
37    @Override
38    public Object getValue(FacesContext context)
39    {
40      return _value;
41    }
42  
43    @Override
44    public void setValue(FacesContext context, Object value)
45    {
46      _value = value;
47    }
48  
49    @Override
50    public boolean isReadOnly(FacesContext context)
51    {
52      return false;
53    }
54  
55    @Override
56    public Class<?> getType(FacesContext context)
57    {
58      return null;
59    }
60  
61    public Object saveState(FacesContext context)
62    {
63      return _value;
64    }
65  
66    public void restoreState(FacesContext context, Object state)
67    {
68      _value = state;
69    }
70  
71    public boolean isTransient()
72    {
73      return _transient;
74    }
75  
76    public void setTransient(boolean newTransientValue)
77    {
78      _transient = newTransientValue;
79    }
80  
81    private boolean _transient;
82    private Object _value;
83  }