View Javadoc

1   /*
2    * Copyright 2004 Anite - Central Government Division
3    * http://www.anite.com/publicsector
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License. You may obtain a copy of
7    * 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, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  package com.anite.antelope.modules.screens.formSample;
18  
19  import org.apache.turbine.modules.screens.VelocityScreen;
20  import org.apache.turbine.util.RunData;
21  import org.apache.velocity.context.Context;
22  
23  import com.anite.antelope.modules.actions.formSample.WhichAnimal;
24  import com.anite.antelope.om.Animal;
25  import com.anite.penguin.form.Field;
26  import com.anite.penguin.modules.tools.FormTool;
27  
28  /***
29   * @author Ben
30   *  
31   */
32  public class AnimalScreen extends VelocityScreen {
33  
34      public static final String AGE = "age";
35  
36      protected void doBuildTemplate(RunData data, Context context)
37              throws Exception {
38          FormTool form = (FormTool) context.get(FormTool.DEFAULT_TOOL_NAME);
39  
40          Field age = (Field) form.getFields().get(AGE);
41  
42          Animal animal = (Animal) data.getSession().getAttribute(
43                  WhichAnimal.ANIMAL);
44          
45          context.put("animal", animal);
46      }
47  
48  }