KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > mlw > vlh > web > ValueListHandlerTilesAction


1 /**
2  * Copyright (c) 2003 held jointly by the individual authors.
3  *
4  * This library is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published
6  * by the Free Software Foundation; either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; with out even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation,
16  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  *
18  * > http://www.gnu.org/copyleft/lesser.html
19  * > http://www.opensource.org/licenses/lgpl-license.php
20  */

21 package net.mlw.vlh.web;
22
23 import java.io.IOException JavaDoc;
24
25 import javax.servlet.ServletContext JavaDoc;
26 import javax.servlet.ServletException JavaDoc;
27 import javax.servlet.http.HttpServletRequest JavaDoc;
28 import javax.servlet.http.HttpServletResponse JavaDoc;
29
30 import net.mlw.vlh.ValueList;
31 import net.mlw.vlh.ValueListHandler;
32 import net.mlw.vlh.ValueListInfo;
33
34 import org.apache.struts.tiles.ComponentContext;
35 import org.apache.struts.tiles.ControllerSupport;
36 import org.springframework.web.context.WebApplicationContext;
37 import org.springframework.web.context.support.WebApplicationContextUtils;
38
39 /**
40  * @author Matthew L. Wilson
41  * @version $Revision: 1.4 $ $Date: 2004/12/13 20:32:35 $
42  */

43 public class ValueListHandlerTilesAction extends ControllerSupport
44 {
45     public static final String JavaDoc VALUE_LIST_NAME = "valueListName";
46     public static final String JavaDoc VALUE_LIST_REQUEST_NAME = "valueListRequestName";
47
48     /**
49      * @see org.apache.struts.tiles.Controller#perform(org.apache.struts.tiles.ComponentContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext)
50      */

51     public void perform(ComponentContext componentContext, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, ServletContext JavaDoc servletContext)
52             throws ServletException JavaDoc, IOException JavaDoc
53     {
54         String JavaDoc name = (String JavaDoc) componentContext.getAttribute(VALUE_LIST_NAME);
55         String JavaDoc requestName = (String JavaDoc) componentContext.getAttribute(VALUE_LIST_REQUEST_NAME);
56
57         WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
58         ValueListHandler vlh = (ValueListHandler) context.getBean("valueListHandler", ValueListHandler.class);
59
60         ValueListInfo info = ValueListRequestUtil.buildValueListInfo(request);
61         ValueList valueList = vlh.getValueList(name, info);
62
63         request.setAttribute(requestName, valueList);
64     }
65
66 }
Popular Tags