KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > tiles > ActionController


1 /*
2  * $Id: ActionController.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.struts.tiles;
20
21 import java.io.IOException JavaDoc;
22
23 import javax.servlet.ServletContext JavaDoc;
24 import javax.servlet.ServletException JavaDoc;
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26 import javax.servlet.http.HttpServletResponse JavaDoc;
27
28 import org.apache.struts.action.Action;
29
30 /**
31  * Struts wrapper implementation of Controller. This implementation wraps an
32  * <code>Action</code> in a <code>Controller</code>.
33  */

34 public class ActionController implements Controller {
35
36     /**
37      * Struts action wrapped.
38      */

39     private Action action = null;
40
41     /**
42      * Constructor.
43      * @param action Action to be wrapped.
44      */

45     public ActionController(Action action) {
46         this.action = action;
47     }
48
49     /**
50      * Method associated to a tile and called immediately before tile is
51      * included. This implementation calls a Struts Action. No servlet is
52      * set by this method.
53      *
54      * @param tileContext Current tile context.
55      * @param request Current request.
56      * @param response Current response.
57      * @param servletContext Current servlet context.
58      */

59     public void perform(
60         ComponentContext tileContext,
61         HttpServletRequest JavaDoc request,
62         HttpServletResponse JavaDoc response,
63         ServletContext JavaDoc servletContext)
64         throws ServletException JavaDoc, IOException JavaDoc {
65
66         try {
67             action.execute(null, null, request, response);
68
69         } catch (Exception JavaDoc e) {
70             throw new ServletException JavaDoc(e);
71         }
72     }
73
74     /**
75      * @see org.apache.struts.tiles.Controller#execute(org.apache.struts.tiles.ComponentContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext)
76      */

77     public void execute(
78         ComponentContext tileContext,
79         HttpServletRequest JavaDoc request,
80         HttpServletResponse JavaDoc response,
81         ServletContext JavaDoc servletContext)
82         throws Exception JavaDoc {
83             
84         this.action.execute(null, null, request, response);
85
86     }
87 }
88
Popular Tags