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.actions; 23 24 import jakarta.servlet.ServletException; 25 import jakarta.servlet.http.HttpServletRequest; 26 import jakarta.servlet.http.HttpServletResponse; 27 28 import org.apache.struts.action.Action; 29 import org.apache.struts.action.ActionForm; 30 import org.apache.struts.action.ActionForward; 31 import org.apache.struts.action.ActionMapping; 32 import org.apache.struts.tiles.ComponentContext; 33 34 /** 35 * Base class for Tiles Actions. 36 * This class has the same role as Struts Action. It provides a method execute(...) 37 * called when action is invoked. The difference is, that the execute() method takes 38 * an additional parameter : tile context. 39 * This class extends Struts Action. Subclasses should override 40 * execute(ComponentContext ...) method instead of Struts 41 * execute(ActionMapping ...) method. 42 * @version $Rev$ $Date$ 43 */ 44 public abstract class TilesAction extends Action { 45 private static final long serialVersionUID = 4536388141271532696L; 46 47 /** 48 * Original Struts Action's method. 49 * Retrieve current Tile context and call TilesAction execute method. 50 * Do not overload this method! 51 * 52 * @param mapping The ActionMapping used to select this instance. 53 * @param form The optional ActionForm bean for this request (if any). 54 * @param request The HTTP request we are processing. 55 * @param response The HTTP response we are creating. 56 * 57 * @exception Exception if the application business logic throws 58 * an exception 59 * @since Struts 1.1 60 */ 61 public ActionForward execute( 62 ActionMapping mapping, 63 ActionForm form, 64 HttpServletRequest request, 65 HttpServletResponse response) 66 throws Exception { 67 68 // Try to retrieve tile context 69 ComponentContext context = ComponentContext.getContext(request); 70 if (context == null) { 71 throw new ServletException( 72 "Can't find Tile context for '" 73 + this.getClass().getName() 74 + "'. TilesAction subclasses must be called from a Tile"); 75 } 76 77 return this.execute(context, mapping, form, request, response); 78 } 79 80 /** 81 * Process the specified HTTP request and create the corresponding HTTP 82 * response (or forward to another web component that will create it), 83 * with provision for handling exceptions thrown by the business logic. 84 * <br> 85 * Override this method to provide functionality. 86 * 87 * @param context The current Tile context, containing Tile attributes. 88 * @param mapping The ActionMapping used to select this instance. 89 * @param form The optional ActionForm bean for this request (if any). 90 * @param request The HTTP request we are processing. 91 * @param response The HTTP response we are creating. 92 * 93 * @exception Exception if the application business logic throws 94 * an exception 95 * @since Struts 1.1 96 */ 97 public ActionForward execute( 98 ComponentContext context, 99 ActionMapping mapping, 100 ActionForm form, 101 HttpServletRequest request, 102 HttpServletResponse response) 103 throws Exception { 104 105 return null; 106 } 107 }