1 /* 2 * $Id$ 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 package org.apache.struts.tiles; 23 24 import java.io.IOException; 25 26 import jakarta.servlet.ServletContext; 27 import jakarta.servlet.ServletException; 28 import jakarta.servlet.http.HttpServletRequest; 29 import jakarta.servlet.http.HttpServletResponse; 30 31 import org.apache.struts.action.Action; 32 33 /** 34 * Struts wrapper implementation of Controller. This implementation wraps an 35 * <code>Action</code> in a <code>Controller</code>. 36 */ 37 public class ActionController implements Controller { 38 private static final long serialVersionUID = -618534639125910093L; 39 40 /** 41 * Struts action wrapped. 42 */ 43 private Action action = null; 44 45 /** 46 * Constructor. 47 * 48 * @param action Action to be wrapped. 49 */ 50 public ActionController(Action action) { 51 this.action = action; 52 } 53 54 /** 55 * Method associated to a tile and called immediately before tile is 56 * included. This implementation calls a Struts Action. No servlet is 57 * set by this method. 58 * 59 * @param tileContext Current tile context. 60 * @param request Current request. 61 * @param response Current response. 62 * @param servletContext Current servlet context. 63 * @deprecated Use execute() instead. This will be removed after 64 * Struts 1.2. 65 */ 66 @Deprecated 67 public void perform( 68 ComponentContext tileContext, 69 HttpServletRequest request, 70 HttpServletResponse response, 71 ServletContext servletContext) 72 throws ServletException, IOException { 73 74 try { 75 action.execute(null, null, request, response); 76 77 } catch (Exception e) { 78 throw new ServletException(e); 79 } 80 } 81 82 /** 83 * @see org.apache.struts.tiles.Controller#execute(org.apache.struts.tiles.ComponentContext, jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, jakarta.servlet.ServletContext) 84 */ 85 public void execute( 86 ComponentContext tileContext, 87 HttpServletRequest request, 88 HttpServletResponse response, 89 ServletContext servletContext) 90 throws Exception { 91 92 this.action.execute(null, null, request, response); 93 94 } 95 }