KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > base > PubBaseAction2


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.modules.base;
7
8 import java.util.*;
9
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11
12 import com.raptus.owxv3.*;
13 import com.raptus.owxv3.api.*;
14
15 /**
16  *
17  * <hr>
18  * <table width="100%" border="0">
19  * <tr>
20  * <td width="24%"><b>Filename</b></td><td width="76%">PubBaseAction.java</td>
21  * </tr>
22  * <tr>
23  * <td width="24%"><b>Author</b></td><td width="76%">Guy Z�rcher (gzuercher@raptus.com)</td>
24  * </tr>
25  * <tr>
26  * <td width="24%"><b>Date</b></td><td width="76%">20th of April 2001</td>
27  * </tr>
28  * </table>
29  * <hr>
30  * <table width="100%" border="0">
31  * <tr>
32  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
33  * </tr>
34  * </table>
35  * <hr>
36  */

37 //public class PubBaseAction2 extends VModuleAnonAction
38
public class PubBaseAction2 extends VModuleRoleAction
39 {
40     /**
41      *
42      */

43     public static final String JavaDoc SECTION_ELEMENT_PROPERTY_MAXROWS = "maxlistrows";
44
45     /**
46      *
47      */

48     protected String JavaDoc dispatchVModuleElement(HttpServletRequest JavaDoc request,
49                                             String JavaDoc element,
50                                             org.apache.struts.action.ActionForm form,
51                                             VModule vm,
52                                             Locale locale)
53     {
54         XMLConfigManager cm = XMLConfigManager.getInstance();
55         // 20020115/gz: BUGFIX: all "elements" are treated the same for the same action!
56
//if(element.compareToIgnoreCase("index2") == 0)
57
//{
58

59             Hashtable hash = new Hashtable();
60             Enumeration pnames = request.getParameterNames();
61             while(pnames.hasMoreElements())
62             {
63                 String JavaDoc key = (String JavaDoc)pnames.nextElement();
64                 hash.put(key, request.getParameter(key));
65             }
66
67             String JavaDoc pageNoParam = request.getParameter("page");
68             //if( ( (((CategoryPagedBean) form).isListLoaded(locale) == false) && pageNoParam != null) || (pageNoParam == null) )
69
if( (((CategoryPagedBean) form).isListLoaded(locale,vm.getIdentification()) == false))
70             {
71                 LoggingManager.log("Loading " + locale.toString() + " public news list from " +
72                                    "database for virtual module " + vm.getIdentification(), this);
73
74                 try
75                 {
76                     CategorySelector old=((CategoryPagedBean) form).getCategorySelector();
77                     CategorySelector sel = new CategorySelector(vm.getLocales(), locale, vm.getIdentification());
78                     if(old!=null) sel.inheritState(old);
79                     ((CategoryPagedBean) form).setCategorySelector(sel);
80                 }
81                 catch(java.sql.SQLException JavaDoc ex)
82                 {
83                     LoggingManager.log("Can't create category selector",this);
84                 }
85
86                 int maxRows = 0;
87 // try
88
// {
89
//LoggingManager.log("element is "+element);
90
// VModuleSectionElement elemObj = vm.getSection(Constants.SECTION_PUBLICS).getElement(element);
91
// if(elemObj != null)
92
// maxRows = elemObj.getIntegerProperty(SECTION_ELEMENT_PROPERTY_MAXROWS);
93
// else
94
// LoggingManager.log("Cannot get element " + element + " from public section of vmodule " +
95
// vm.getIdentification(), this);
96
maxRows=cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/section/publics/element?name="+element+"/property?name=maxlistrow", "value");
97 // }
98
// catch(ParseException e) {
99
// LoggingManager.log("ParseException while retrieving custom vm properties!", this);
100
// }
101

102                 // initialize the business object
103
BaseObject nwobj = new BaseObject(vm, locale);
104                 Vector newsList = nwobj.loadPubBaseListEntries(null);
105
106
107
108                 //LoggingManager.log("Vector size="+newsList.size());
109
// pass the list to the bean (in scope)
110
((CategoryPagedBean) form).setMaxRows(maxRows);
111                 ((CategoryPagedBean) form).setList(newsList, locale, vm.getIdentification());
112                 ((CategoryPagedBean) form).setURI(request.getRequestURI());
113             }
114             else
115             {
116                 // just tell the bean what page of the list to display
117
LoggingManager.log("Using session copy of public news list for virtual module " +
118                                    vm.getIdentification(), this);
119                 int pageNo = 1;
120                 if(pageNoParam != null)
121                 {
122                     try
123                     {
124                         pageNo = Integer.parseInt(pageNoParam);
125                     }
126                     catch(NumberFormatException JavaDoc e) {
127                         LoggingManager.log("NumberFormatException while converting parameter <page> " + pageNoParam, this);
128                     }
129                 }
130
131                 ((PagedListBean) form).setCurrentPage(pageNo);
132             }
133
134             // update our filter :))
135
((CategoryPagedBean) form).setValues(hash);
136             // return the requested action
137
return Constants.SECTION_PUBLICS + Constants.DEFAULT_SPACER + element;
138         //}
139

140         //return null; // unknown action
141
}
142
143 }
144
145 // eof
146
Popular Tags