2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shale.view;
19  
20  import javax.faces.context.FacesContext;
21  import org.apache.shale.view.faces.FacesConstants;
22  
23  
24  /***
25   * <p>{@link AbstractViewController} is a convenience base implementation of
26   * {@link ViewController}.  It also provides convenience methods inherited
27   * from {@link AbstractFacesBean} to all of its subclasses.</p>
28   *
29   * $Id: AbstractViewController.java 478339 2006-11-22 22:03:44Z craigmcc $
30   */
31  
32  public abstract class AbstractViewController extends AbstractFacesBean
33      implements ViewController {
34  
35  
36      // ------------------------------------------------------------- Constructor
37  
38  
39      /***
40       * <p>Pre-initialize the <code>postBack</code> property appropriately
41       * if we can.</p>
42       */
43      public AbstractViewController() {
44  
45          FacesContext context = FacesContext.getCurrentInstance();
46          if ((context != null)
47              && context.getExternalContext().getRequestMap().containsKey(FacesConstants.VIEW_POSTBACK)) {
48              setPostBack(true);
49          }
50  
51      }
52  
53  
54  
55      // -------------------------------------------------------------- Properties
56  
57  
58      /***
59       * <p>Flag indicating that this is a postback request.</p>
60       */
61      private boolean postBack = false;
62  
63  
64      /*** {@inheritDoc} */
65      public boolean isPostBack() {
66  
67          return this.postBack;
68  
69      }
70  
71  
72      /*** {@inheritDoc} */
73      public void setPostBack(boolean postBack) {
74  
75          this.postBack = postBack;
76  
77      }
78  
79  
80      // ---------------------------------------------------------- Public Methods
81  
82  
83      /***
84       * <p>The default implementation does nothing.</p>
85       */
86      public void destroy() {
87          // do nothing
88      }
89  
90  
91      /***
92       * <p>The default implementation does nothing.</p>
93       */
94      public void init() {
95          // do nothing
96      }
97  
98  
99      /***
100      * <p>The default implementation does nothing.</p>
101      */
102     public void preprocess() {
103         // do nothing
104     }
105 
106 
107     /***
108      * <p>The default implementation does nothing.</p>
109      */
110     public void prerender() {
111         // do nothing
112     }
113 
114 
115 }