working on struts/hibernate for content-admin
[mir.git] / source / mir / core / ui / servlet / TemplateServlet.java
index 78e4008..5ec2abd 100755 (executable)
@@ -53,6 +53,9 @@ import javax.servlet.http.HttpSession;
 
 import mir.config.MirPropertiesConfiguration;
 import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
+import mir.core.service.storage.ArticleTypeService;
+import mir.core.service.storage.LanguageService;
+import mir.core.service.storage.TopicService;
 import mir.servlet.ServletModuleExc;
 import mir.util.GeneratorDateTimeFunctions;
 import mir.util.GeneratorExpressionFunctions;
@@ -66,13 +69,14 @@ import mir.util.StringRoutines;
 import mircoders.global.MirGlobal;
 import mircoders.servlet.ServletHelper;
 import multex.Failure;
+import net.sf.hibernate.SessionFactory;
 
 import org.apache.struts.util.MessageResources;
 
 /**
  * TemplateServlet
  * @author idefix
- * @version $Id: TemplateServlet.java,v 1.3 2003/09/18 21:42:17 idfx Exp $
+ * @version $Id: TemplateServlet.java,v 1.4 2003/12/20 20:27:10 idfx Exp $
  */
 public class TemplateServlet extends HttpServlet {
        private MirPropertiesConfiguration _configuration;
@@ -115,7 +119,23 @@ public class TemplateServlet extends HttpServlet {
        protected void process(HttpServletRequest request, HttpServletResponse response) 
                throws IOException, ServletException {
                try {
-                       setLoginLanguages(this.getServletContext());
+                       //setting some data which are needed often
+                       //should be done a bit smarter
+                       setLoginLanguages(getServletContext());
+                       ServletContext context = getServletContext();
+                       TopicService topicService = 
+                               new TopicService((SessionFactory)context
+                                       .getAttribute(ServletConstants.SESSION_FACTORY));
+                       LanguageService languageService = 
+                               new LanguageService((SessionFactory)context
+                                       .getAttribute(ServletConstants.SESSION_FACTORY));
+                       ArticleTypeService articleTypeService = 
+                               new ArticleTypeService((SessionFactory)context
+                                       .getAttribute(ServletConstants.SESSION_FACTORY));
+                       context.setAttribute(ServletConstants.TOPICS, topicService.list());
+                       context.setAttribute(ServletConstants.LANGUAGES, languageService.list());
+                       context.setAttribute(ServletConstants.ARTICLE_TYPES, articleTypeService.list());
+                       
                        
                        Map requestData = new HashMap();
                        Enumeration keys = request.getAttributeNames();