Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VelocityAction |
|
| 1.75;1,75 |
1 | package org.apache.turbine.modules.actions; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import org.apache.turbine.modules.screens.TemplateScreen; | |
23 | import org.apache.turbine.pipeline.PipelineData; | |
24 | import org.apache.turbine.util.velocity.VelocityActionEvent; | |
25 | import org.apache.velocity.context.Context; | |
26 | ||
27 | /** | |
28 | * This class provides a convenience methods for Velocity Actions to use. Since | |
29 | * this class is abstract, it should only be extended and not used directly. | |
30 | * | |
31 | * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a> | |
32 | * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a> | |
33 | * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a> | |
34 | * @version $Id: VelocityAction.java 1854786 2019-03-04 18:29:18Z tv $ | |
35 | */ | |
36 | 33 | public abstract class VelocityAction extends VelocityActionEvent |
37 | { | |
38 | /** | |
39 | * Initialize the module. | |
40 | * | |
41 | * @throws Exception a generic exception. | |
42 | */ | |
43 | @Override | |
44 | public void initialize() throws Exception | |
45 | { | |
46 | 33 | initialized = true; |
47 | 33 | } |
48 | ||
49 | /** | |
50 | * You SHOULD override this method and implement it in your action. | |
51 | * | |
52 | * @param pipelineData Turbine information. | |
53 | * @param context Context for web pages. | |
54 | * @throws Exception a generic exception. | |
55 | */ | |
56 | public abstract void doPerform(PipelineData pipelineData, Context context) | |
57 | throws Exception; | |
58 | ||
59 | /** | |
60 | * Sets up the context and then calls super.perform(); thus, subclasses | |
61 | * don't have to worry about getting a context themselves! If a subclass | |
62 | * throws an exception then depending on whether | |
63 | * action.event.bubbleexception is true, then it bubbles it farther up, or | |
64 | * traps it there. | |
65 | * | |
66 | * @param pipelineData Turbine information. | |
67 | * @throws Exception a generic exception. | |
68 | */ | |
69 | @Override | |
70 | public void perform(PipelineData pipelineData) throws Exception | |
71 | { | |
72 | try | |
73 | { | |
74 | 33 | super.perform(pipelineData); |
75 | } | |
76 | 12 | catch (Exception e) |
77 | { | |
78 | 12 | if (bubbleUpException) |
79 | { | |
80 | 6 | throw e; |
81 | } | |
82 | 21 | } |
83 | 27 | } |
84 | ||
85 | /** | |
86 | * This method is used when you want to short circuit an Action and change | |
87 | * the template that will be executed next. | |
88 | * | |
89 | * @param pipelineData Turbine information. | |
90 | * @param template The template that will be executed next. | |
91 | */ | |
92 | public void setTemplate(PipelineData pipelineData, String template) | |
93 | { | |
94 | 0 | TemplateScreen.setTemplate(pipelineData, template); |
95 | 0 | } |
96 | } |