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.usecases.symbols;
19  
20  import java.util.Map;
21  
22  import org.apache.shale.view.AbstractViewController;
23  
24  /***
25   * <p>This view controller manages state outside of the managed beans 
26   * associated with the form.  It's purpose is to respond to the loading 
27   * of the page and processing the posted events.</p>
28   */
29  public class RegistrationForm extends AbstractViewController {
30      
31      /***
32       * <p>This view controller is scoped in the request. The init method
33       * is invoked for each request and the page's state is stored in
34       * session scoped beans. The dialog for these session scoped
35       * beans are managed through this stateless controller.
36       * This separation of view model data and action controller is similar 
37       * to Struts Action 1.x.</p> 
38       */
39      public void init() {
40          
41          String init = (String) ((Map) getBean("param")).get("init");
42          boolean isInit = Boolean.valueOf(init).booleanValue();
43          if (isInit) {
44              BasicPerson person = new BasicPerson();
45              person.setFirstName("Gary");
46              person.setLastName("VanMatre");
47              setBean("basicPerson", person);
48              
49              setBean("fullPerson", new FullPerson());
50              setBean("businessPerson", new BusinessPerson());
51          }
52      }
53      
54      /***
55       * <p>Handles action of saving the pages state.</p> 
56       */
57      public String save() {      
58          return "save";
59      }
60      
61  }