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   * $Id: Lifecycle2.java 490577 2006-12-27 22:19:21Z craigmcc $
18   */
19  
20  package org.apache.shale.examples.test.tiger;
21  
22  import javax.faces.context.FacesContext;
23  import org.apache.shale.tiger.managed.Bean;
24  import org.apache.shale.tiger.managed.Property;
25  import org.apache.shale.tiger.managed.Scope;
26  import org.apache.shale.tiger.view.Destroy;
27  import org.apache.shale.tiger.view.Init;
28  import org.apache.shale.tiger.view.Preprocess;
29  import org.apache.shale.tiger.view.Prerender;
30  import org.apache.shale.tiger.view.View;
31  
32  /***
33   * <p>Second page for lifecycle event tests.</p>
34   */
35  @Bean(name="lifecycle2", scope=Scope.REQUEST) @View
36  public class Lifecycle2 {
37      
38  
39      // -------------------------------------------------------------- Properties
40  
41  
42      // The "Recorder" object for this request
43      @Property(value="#{recorder}")
44      private Recorder recorder = null;
45      public Recorder getRecorder() {
46          return this.recorder;
47      }
48      public void setRecorder(Recorder recorder) {
49          this.recorder = recorder;
50      }
51  
52  
53      // ------------------------------------------------------- Lifecycle Methods
54  
55  
56      /***
57       * <p>Record an init event.</p>
58       */
59      @Init
60      public void init() {
61          getRecorder().record("init2");
62          System.out.println("Lifecycle2.init()");
63          if (FacesContext.getCurrentInstance() == null) {
64              getRecorder().record("noContext");
65              System.out.println("  noContext");
66          }
67      }
68  
69  
70      /***
71       * <p>Record a preprocess event.</p>
72       */
73      @Preprocess
74      public void preprocess() {
75          getRecorder().record("preprocess2");
76          System.out.println("Lifecycle2.preprocess()");
77      }
78  
79  
80      /***
81       * <p>Record a prerender event.</p>
82       */
83      @Prerender
84      public void prerender() {
85          getRecorder().record("prerender2");
86          System.out.println("Lifecycle2.prerender()");
87      }
88  
89  
90      /***
91       * <p>Record a destroy event.</p>
92       */
93      @Destroy
94      public void destroy() {
95          getRecorder().record("destroy2");
96          System.out.println("Lifecycle2.destroy()");
97          if (FacesContext.getCurrentInstance() == null) {
98              getRecorder().record("noContext");
99              System.out.println("  noContext");
100         }
101     }
102 
103 
104 }