KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > webapp > tiles > test > TestTileController


1 /*
2  * $Id: TestTileController.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.webapp.tiles.test;
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.tiles.ComponentContext;
29 import org.apache.struts.tiles.ControllerSupport;
30
31
32   /**
33    * Controller example.
34    * This controller modify title by adding "ok".
35    */

36 public class TestTileController extends ControllerSupport
37 {
38
39   public TestTileController()
40     {
41     }
42
43    /**
44     * Method associated to a tile and called when immediately before tile is included.
45     * @param tileContext Current tile context.
46     * @param request Current request
47     * @param response Current response
48     * @param servletContext Current servlet context
49     */

50    public void perform(ComponentContext tileContext,
51                        HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response,
52                        ServletContext JavaDoc servletContext)
53         throws ServletException JavaDoc, IOException JavaDoc
54    {
55    System.out.println( "Controller called" );
56
57
58    String JavaDoc title = (String JavaDoc)tileContext.getAttribute("title");
59    title += "- controller called";
60    tileContext.putAttribute( "title", title);
61    }
62
63
64 }
65
Popular Tags