KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > categories > EACategoryListAction


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

5
6 package com.raptus.owxv3.modules.categories;
7
8 import javax.servlet.http.HttpServletRequest JavaDoc;
9
10 import org.apache.struts.action.*;
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%">EACategoryListAction.java</td>
21  * </tr>
22  * <tr>
23  * <td width="24%"><b>Author</b></td><td width="76%">REEA</td>
24  * </tr>
25  * <tr>
26  * <td width="24%"><b>Date</b></td><td width="76%">10th of December 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  *
36  * <table width="100%" border="0">
37  * <tr>
38  * <td>This class is the action class of the list category screen.</td>
39  * </tr>
40  * </table>
41  * <hr>
42  */

43 //public class EACategoryListAction extends VModuleAuthAction
44
public class EACategoryListAction extends VModuleRoleAction
45 {
46     /**
47      *This method is called to list all the categories, or
48      *with action delete to delete a category
49      */

50     public String JavaDoc dispatchVModuleElement(HttpServletRequest JavaDoc request,
51                                          String JavaDoc element,
52                                          org.apache.struts.action.ActionForm form,
53                                          VModule vm,
54                                          com.raptus.owxv3.api.usermgr.User user)
55     {
56
57         if(element.compareToIgnoreCase(CategoryConstants.ELEMENT_LIST) == 0)
58         {
59             EACategoryListBean listbean=(EACategoryListBean) form;
60
61             String JavaDoc action="";
62              //Checking what kind of action should perform
63
if(request.getParameter(CategoryConstants.HTTPGET_PARAM_ACTION)!=null)
64                 action=request.getParameter(CategoryConstants.HTTPGET_PARAM_ACTION);
65
66
67             if(action.compareToIgnoreCase(CategoryConstants.VMODULE_ACTION_DELETE)==0)
68             {
69                 int catid=0;
70
71                 /**
72                  *We need the catid of the category that should be deleted
73                  */

74                 try
75                 {
76                     if(request.getParameter(CategoryConstants.HTTPGET_PARAM_CATID)!=null)
77                        catid=Integer.parseInt( request.getParameter(CategoryConstants.HTTPGET_PARAM_CATID) );
78                 }catch(NumberFormatException JavaDoc nfe){}
79
80                 if(catid!=0)
81                 {
82
83                    CategoriesObject catobj=new CategoriesObject();
84
85                    int deleteres=catobj.deleteCategory(catid);
86                    ActionErrors errors=new ActionErrors();
87                    /*
88                     *Checking if the delete retuned errors or not
89                     */

90                    if(deleteres==CategoryConstants.RESPONSE_NOTEMTPY_ERROR)
91                    {
92                        errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("module.categories.error.categorynotempty") );
93                    }
94                    else if(deleteres==CategoryConstants.RESPONSE_NODELETESTATIC_ERROR)
95                    {
96                        errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("module.categories.error.nodeletestaticcat") );
97                    }
98                    else if(deleteres==CategoryConstants.RESPONSE_SQLERROR)
99                    {
100                        errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("module.categories.error.sqlerror") );
101                    }
102                    if(errors.size()>0)
103                    {
104                         saveErrors(request,errors);
105
106                    }
107                 }//end big if
108
}
109
110
111
112             //the category list should be reloaded all the time
113
try
114             {
115                 listbean.setCategorySelector( new CategorySelector(vm.getLocales(),user.getLocale()) );
116             }catch(Exception JavaDoc e)
117             {
118                 LoggingManager.log("Error while adding the CategorySelector!"+e,this);
119             }
120
121
122
123         }
124         else
125             return null; // display unknown element screen
126

127         return Constants.SECTION_EADMIN + Constants.DEFAULT_SPACER + element;
128
129     }
130
131 }
132
133 // eof
134
Popular Tags