<%-- 
    Document   : EntryAdmin
    Created on : 2013-5-2, 11:32:59
    Author     : root
    param:create update list get initUpdate delete
  /gcms/admin/ArticleCat/action/ArticleCatAdminAction.jsp

urlPath: 
/gcms/admin/ArticleCat/action/ArticleCatAdminAction.jsp?act=create
&id=null


--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="gcms.dao.CmsArticleCat,gcms.dao.CmsArticleCatFormFacade,gcms.dao. service.CmsArticleCatEntryService"%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Entry Admin Action</title>
    </head>
    <body>
        <h1>Entry Admin Action</h1>
        <%
    String act=request.getParameter("act");        
        %>
        <div > 
        
        <%
        out.write("Action:"+act);
        if(request.getAttribute("info")!=null){
            String info=(String)request.getAttribute("info");
            out.write("系统消息："+info);
        }
    %>
        </div>
        
        <%
        String action_path="/gcms/admin/ArticleCat/action/ArticleCatAdminAction.jsp";
        String update_path="/gcms/admin/entryJsp/CmsArticleCatUpdate.jsp";
        String add_path="/gcms/admin/entryJsp/CmsArticleCatFormAdd.jsp";
        String admin_path="/gcms/admin/ArticleCat/admin.jsp";
        String view_path="/gcms/admin/entryJsp/CmsArticleCatView.jsp";
        String list_path="/gcms/admin/entryJsp/CmsArticleCatList.jsp";
        String error_action_noFindpath="/gcms/error/nofindActionPath.jsp";
          
            
            if(act!=null&& act.contains("create")){
                CmsArticleCatFormFacade facede=new CmsArticleCatFormFacade();
                gcms.dao.CmsArticleCat entry=(CmsArticleCat)facede.formToEntry_add(request);
                CmsArticleCatEntryService dao=new CmsArticleCatEntryService();
                dao.add(entry);
               
                request.setAttribute("info","Add "+entry.getCatName()+" Success!");
                
                  String toAdminPath=action_path+"?act=admin";
                request.getRequestDispatcher(toAdminPath).forward(request, response);
          
            } else
            
              if(act!=null&& act.contains("update")){
                CmsArticleCatFormFacade facede=new CmsArticleCatFormFacade();
                gcms.dao.CmsArticleCat entry=(gcms.dao.CmsArticleCat)facede.formToEntry_update(request);
                CmsArticleCatEntryService dao=new CmsArticleCatEntryService();
                dao.update(entry);
                String toAdmin=action_path+"?act=admin";
                request.getRequestDispatcher(toAdmin).forward(request, response);
            } else
           
            if(act!=null&& act.contains("delete")){
               // CmsArticleCatFormFacade facede=new CmsArticleCatFormFacade();
               // gcms.dao.CmsArticleCat entry=(CmsArticleCat)facede.formToEntry_add(request);
                Integer id=Integer.parseInt(request.getParameter("id"));
                CmsArticleCatEntryService dao=new CmsArticleCatEntryService();
                dao.delete(id);
                
                  String toadminAction=action_path+"?act=admin";
                 request.getRequestDispatcher(toadminAction).forward(request, response);
        
             
            }else
            
            if(act!=null&& act.contains("get")){
               
                  Integer id=Integer.parseInt(request.getParameter("id"));
                CmsArticleCatEntryService dao=new CmsArticleCatEntryService();
                dao.delete(id);
               CmsArticleCat e= (CmsArticleCat) dao.get(id);
               request.setAttribute("CmsArticleCat", e);
               
              //  String toAdmin=action_path+"?act=admin";
                request.getRequestDispatcher(view_path).forward(request, response);
      
            }else
                        
            if(act!=null&& act.contains("initUpdate")){
            Integer id=Integer.parseInt(request.getParameter("id"));
                CmsArticleCatEntryService dao=new CmsArticleCatEntryService();
                dao.delete(id);
               CmsArticleCat e= (CmsArticleCat) dao.get(id);
               request.getSession().setAttribute("CmsArticleCat", e);
            
            request.getRequestDispatcher(update_path).forward(request, response);
      
            }
            else
             if(act!=null&& act.contains("admin")){
                 CmsArticleCatEntryService dbUtil=new CmsArticleCatEntryService();
                 
                CmsArticleCatFormFacade facede=new CmsArticleCatFormFacade();
                
                String sql=" ";
                
               List<CmsArticleCat> entryList=
                      dbUtil.getListAll();
                CmsArticleCatEntryService dao=new CmsArticleCatEntryService();
                
                request.setAttribute("objectList", entryList);
                
                 request.getRequestDispatcher(admin_path).forward(request, response);
        
                
            }else{
            //error
            
               request.getRequestDispatcher(error_action_noFindpath).forward(request, response);
        
            }
            
            
        %>
    </body>
</html>
