1 21 package net.mlw.vlh.web; 22 23 import java.io.IOException ; 24 25 import javax.servlet.ServletContext ; 26 import javax.servlet.ServletException ; 27 import javax.servlet.http.HttpServletRequest ; 28 import javax.servlet.http.HttpServletResponse ; 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 43 public class ValueListHandlerTilesAction extends ControllerSupport 44 { 45 public static final String VALUE_LIST_NAME = "valueListName"; 46 public static final String VALUE_LIST_REQUEST_NAME = "valueListRequestName"; 47 48 51 public void perform(ComponentContext componentContext, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) 52 throws ServletException , IOException 53 { 54 String name = (String ) componentContext.getAttribute(VALUE_LIST_NAME); 55 String requestName = (String ) 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 |