1 package action; 2 3 import java.util.List ; 4 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpServletResponse ; 7 8 import org.apache.struts.action.Action; 9 import org.apache.struts.action.ActionForm; 10 import org.apache.struts.action.ActionForward; 11 import org.apache.struts.action.ActionMapping; 12 import org.objectstyle.cayenne.access.DataContext; 13 import org.objectstyle.cayenne.conf.ServletUtil; 14 import org.objectstyle.cayenne.query.SelectQuery; 15 16 import webtest.Gallery; 17 18 public class GalleryPageAction extends Action { 19 20 public ActionForward execute( 21 ActionMapping mapping, 22 ActionForm form, 23 HttpServletRequest request, 24 HttpServletResponse response) 25 throws Exception { 26 27 DataContext ctxt = 28 ServletUtil.getSessionContext(request.getSession()); 29 30 SelectQuery query = new SelectQuery(Gallery.class); 31 32 List galleries = ctxt.performQuery(query); 33 request.setAttribute("galleries", galleries); 34 35 return mapping.findForward("success"); 36 } 37 38 } 39 | Popular Tags |