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: Managed.java 495383 2007-01-11 21:31:37Z rahul $
18   */
19  
20  package org.apache.shale.examples.test.tiger;
21  
22  import org.apache.shale.tiger.managed.Bean;
23  import org.apache.shale.tiger.managed.Property;
24  import org.apache.shale.tiger.managed.Scope;
25  import org.apache.shale.tiger.view.Destroy;
26  import org.apache.shale.tiger.view.Init;
27  import org.apache.shale.tiger.view.Preprocess;
28  import org.apache.shale.tiger.view.Prerender;
29  import org.apache.shale.tiger.view.View;
30  
31  /***
32   * <p>View controller for the <code>/managed.jsp</code> view,
33   * completely configured via annotations.</p>
34   */
35  @Bean(name="managed", scope=Scope.REQUEST)
36  @View
37  public class Managed {
38      
39  
40      // ------------------------------------------------------- Public Properties
41  
42  
43      /***
44       * <p>Injected application bean instance.</p>
45       */
46      @Property(value="#{applicationBean}")
47      private ApplicationBean applicationBean;
48  
49      public ApplicationBean getApplicationBean() {
50          return this.applicationBean;
51      }
52  
53      public void setApplicationBean(ApplicationBean applicationBean) {
54          this.applicationBean = applicationBean;
55      }
56  
57  
58      /***
59       * <p>Return the events that have occurred so far.</p>
60       */
61      private StringBuffer events = new StringBuffer();
62  
63      public String getEvents() {
64          return events.toString();
65      }
66  
67  
68  
69      /***
70       * <p>Injected request bean instance.</p>
71       */
72      @Property(value="#{requestBean}")
73      private RequestBean requestBean;
74  
75      public RequestBean getRequestBean() {
76          return this.requestBean;
77      }
78  
79      public void setRequestBean(RequestBean requestBean) {
80          this.requestBean = requestBean;
81      }
82  
83  
84      /***
85       * <p>Injected session bean instance.</p>
86       */
87      @Property(value="#{sessionBean}")
88      private SessionBean sessionBean;
89  
90      public SessionBean getSessionBean() {
91          return this.sessionBean;
92      }
93  
94      public void setSessionBean(SessionBean sessionBean) {
95          this.sessionBean = sessionBean;
96      }
97  
98  
99      // -------------------------------------------------------- Lifecycle Events
100 
101 
102     @Init
103     public void myInit() {
104         events.append("init/");
105         System.out.println("ManagedBean.init()");
106     }
107 
108 
109     @Preprocess
110     public void myPreprocess() {
111         events.append("preprocess/");
112         System.out.println("ManagedBean.preprocess()");
113     }
114 
115 
116     @Prerender
117     public void myPrerender() {
118         events.append("prerender/");
119         System.out.println("ManagedBean.prerender()");
120     }
121 
122 
123     @Destroy
124     public void myDestroy() {
125         events.append("destroy/");
126         System.out.println("ManagedBean.destroy()");
127     }
128 
129 
130     // ------------------------------------------------------------- View Events
131 
132 
133     // Process a click on the resubmit link
134     public String resubmit() {
135         System.out.println("ManagedBean.resubmit()");
136         return null;
137     }
138 
139 
140 }