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");
6 * you may not use this file except in compliance with the License.
7 * 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 com.anite.antelope.modules.actions.formSample;
19
20 import org.apache.turbine.modules.actions.VelocityAction;
21 import org.apache.turbine.util.RunData;
22 import org.apache.velocity.context.Context;
23
24 import com.anite.penguin.modules.tools.FormTool;
25
26 /***
27 * Created 05-May-2004
28 */
29 public class SimpleFormSubmit extends VelocityAction {
30
31
32 /***
33 * Process the simple form data
34 * All control over the form flow is handled in this action. If you wish this
35 * to be more automated look at the Zebra samples.
36 */
37 public void doPerform(RunData data, Context context) throws Exception {
38
39
40 FormTool form = (FormTool) context.get(FormTool.DEFAULT_TOOL_NAME);
41
42 if (form.isAllValid()){
43 // Passed all validation
44 //@TODO do sample
45 // Go to success URL
46 data.setScreenTemplate("formSample,Success.vm");
47 } else {
48 // Failed some validation
49
50 // Return to previous screen
51 data.setScreenTemplate("formSample,SimpleForm.vm");
52 }
53
54 }
55 }