KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > module > news > ShowNewsModule


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.news;
24
25
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
34 import com.geinuke.common.GlobalConfigurationI;
35 import com.geinuke.common.ModuleWidgetI;
36 import com.geinuke.common.NukeModuleI;
37 import com.geinuke.common.PageTool;
38 import com.geinuke.common.UserI;
39 import com.geinuke.middle.ICommentBL;
40 import com.geinuke.middle.INewsBL;
41 import com.geinuke.middle.IUserBL;
42 import com.geinuke.module.ModuleWriter;
43 import com.geinuke.servlet.GeiServlet;
44 import com.geinuke.util.NukeResource;
45 import com.geinuke.vo.ModuleDBVO;
46 import com.geinuke.vo.NewsVO;
47 import com.geinuke.vo.UserVO;
48
49 public class ShowNewsModule implements ModuleWidgetI{
50
51     public NukeModuleI handleAction(ModuleDBVO module, Context ctx,HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res, UserI user, GlobalConfigurationI gConf) throws Exception JavaDoc {
52         NukeModuleI mod=null;
53         String JavaDoc moduleTempName=null;
54         HashMap JavaDoc writersC=null;
55         INewsBL nbl=(INewsBL)GeiServlet.getBL("INewsBL");
56         IUserBL ubl=(IUserBL)GeiServlet.getBL("IUserBL");
57         ICommentBL cbl=(ICommentBL)GeiServlet.getBL("ICommentBL");
58         
59         int id= Integer.parseInt( req.getParameter("id") ) ;
60         NewsVO n=nbl.getNewsByNId(id);
61         UserVO us=ubl.getUserByID(n.getUId());
62         
63         
64         writersC=cbl.getUsersByCommentXId(n.getNId());
65         ctx.put("writersC",writersC);
66         ctx.put("user",user);
67         Locale JavaDoc lo=NukeResource.getLocale(req,res);
68         
69         ctx.put("pageTool",new PageTool(lo));
70         GeiServlet.intLog(" &&&& "+req.getParameter("op"));
71         if(req.getParameter("op").equals("printNews"))
72             ctx.put("NOTEMPLATE","NOTEMPLATE");
73         moduleTempName=gConf.getModulePage(module.getName(),req);
74         
75         
76         ctx.put("news",n);
77         ctx.put("writer",us);
78         
79         mod=ModuleWriter.fill(ctx,module,moduleTempName);
80         return mod;
81     }
82
83 }
Popular Tags