KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > module > admin > disablednews > AdminDisabledNewsHome


1
2  /*
3  -- GeiNuke --
4 Copyright (c) 2005 by Roberto Sidoti [geinuke@users.sourceforge.net]
5  http://www.hostingjava.it/-geinuke/
6
7 This file is part of GeiNuke.
8
9     GeiNuke is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     GeiNuke is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with GeiNuke; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */

23 package com.geinuke.module.admin.disablednews;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.util.Locale JavaDoc;
28
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
31
32 import org.apache.velocity.context.Context;
33 import com.geinuke.common.GlobalConfigurationI;
34 import com.geinuke.common.ModuleWidgetI;
35 import com.geinuke.common.NukeModuleI;
36 import com.geinuke.common.PageTool;
37 import com.geinuke.common.UserI;
38 import com.geinuke.middle.INewsBL;
39 import com.geinuke.module.ModuleWriter;
40 import com.geinuke.servlet.GeiServlet;
41 import com.geinuke.util.NukeResource;
42 import com.geinuke.util.Paginator;
43 import com.geinuke.vo.ModuleDBVO;
44 import com.geinuke.vo.NewsVO;
45
46
47
48 public class AdminDisabledNewsHome implements ModuleWidgetI{
49
50     protected void checkSingleUpdate(HttpServletRequest JavaDoc req) throws Exception JavaDoc{
51         String JavaDoc upd=req.getParameter("upd");
52         if(upd!=null){
53             int id=Integer.parseInt(upd);
54             INewsBL nbl=(INewsBL)GeiServlet.getBL("INewsBL");
55             NewsVO n=nbl.getNewsByNId(id);
56             n.setEnabled(true);
57             INewsBL bl=(INewsBL)GeiServlet.getBL("INewsBL");
58             bl.updateNews(n);
59         }
60     }
61     
62     
63     
64     public NukeModuleI handleAction(ModuleDBVO module, Context ctx,HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res, UserI user, GlobalConfigurationI gConf) throws Exception JavaDoc {
65         NukeModuleI mod=null;
66         String JavaDoc moduleTempName=null;
67         ArrayList JavaDoc list=null,enList=null;
68         HashMap JavaDoc writerList=null,enWL=null;
69         moduleTempName=gConf.getModulePage(module.getName(),req);
70         this.checkSingleUpdate(req);
71         INewsBL bl=(INewsBL)GeiServlet.getBL("INewsBL");
72         list=bl.getDisabledNews();
73         enList=bl.getEnabledNews();
74         writerList=bl.getAutorList(list);
75         enWL=bl.getAutorList(enList);
76         
77         ctx.put("writerList",writerList);
78         ctx.put("enWL",enWL);
79         
80         Locale JavaDoc lo=NukeResource.getLocale(req,res);
81         
82         ctx.put("pageTool",new PageTool(lo));
83         
84         ctx.put("list",list);
85         String JavaDoc pag=req.getParameter("wp");
86         Paginator pager=new Paginator(enList,10,"Admin.jhtm?"+req.getQueryString());
87         if(pag!=null){
88             enList=pager.getPage(Integer.parseInt(pag));
89         }else{
90             enList=pager.getPage(1);
91         }
92         
93         ctx.put("pag",pager);
94         ctx.put("enList",enList);
95         mod=ModuleWriter.fill(ctx,module,moduleTempName);
96         return mod;
97     }
98
99 }
100
101
Popular Tags