package sample.tiles;
import org.apache.struts.tiles.Controller;
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.beans.SimpleMenuItem;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import java.util.List;
import java.util.ArrayList;
public class DynaMenuController implements Controller{
public void execute(ComponentContext context,
HttpServletRequest request,
HttpServletResponse response,
ServletContext servletContext){
// メニューリストを作成する
List<SimpleMenuItem> menuList=new ArrayList<SimpleMenuItem>();
SimpleMenuItem menu = new SimpleMenuItem();
menu.setValue("メニュー1");
menu.setLink("/jsp/tiles_jsp/menu_link_01.jsp");
menuList.add(menu);
menu = new SimpleMenuItem();
menu.setValue("メニュー2");
menu.setLink("/jsp/tiles_jsp/menu_link_02.jsp");
menuList.add(menu);
menu = new SimpleMenuItem();
menu.setValue("メニュー3");
menu.setLink("/jsp/tiles_jsp/menu_link_03.jsp");
menuList.add(menu);
// メニューリストを登録する
context.putAttribute("menuList", menuList);
}
public void perform(ComponentContext context,
HttpServletRequest request,
HttpServletResponse response,
ServletContext servletContext){
}
}
|