KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > VModuleAnonAction


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

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

40 public class VModuleAnonAction extends OmniaWebAction
41 {
42     /**
43      * Process the specified HTTP request, and create the corresponding HTTP
44      * response (or forward to another web component that will create it).
45      * Return an <code>ActionForward</code> instance describing where and how
46      * control should be forwarded, or <code>null</code> if the response has
47      * already been completed.
48      *
49      * @param mapping The ActionMapping used to select this instance
50      * @param actionForm The optional ActionForm bean for this request (if any)
51      * @param request The HTTP request we are processing
52      * @param response The HTTP response we are creating
53      *
54      * @exception IOException if an input/output error occurs
55      * @exception ServletException if a servlet exception occurs
56      */

57     public ActionForward perform(ActionMapping mapping,
58                  ActionForm form,
59                  HttpServletRequest request,
60                  HttpServletResponse response)
61     throws IOException JavaDoc, ServletException JavaDoc
62     {
63         String JavaDoc element = getSelectedElement(form, request);
64         if(element == null || element.length() == 0)
65         {
66             LoggingManager.log("Parameter <element> not specified. Displaying " +
67                                "error screen.", this);
68             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT);
69         }
70
71         String JavaDoc vmid = getSelectedVModule(form, request);
72         if(vmid == null || vmid.length() == 0)
73         {
74             LoggingManager.log("Parameter <vmodule> not specified. Element was " + element
75                                + Constants.DEFAULT_SPACER + " Displaying error screen.", this);
76             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNVMODULE);
77         }
78
79         Locale JavaDoc locale = getSelectedLocale(form, request);
80         if(locale == null)
81         {
82             LoggingManager.log("Parameter <locale> not specified. Element was " + element
83                                + Constants.DEFAULT_SPACER + " Displaying error screen.", this);
84             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNLOCALE);
85         }
86
87         // first retrieve module, to check if locale is available
88
HttpSession session = request.getSession();
89         VModule vm = cachedVModuleAccess(session, vmid);
90         if(vm == null)
91         {
92             LoggingManager.log("FAILED to retrieve a valid virtual module from session.", this);
93             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNVMODULE);
94         }
95
96         // set the locale for the request
97
if(vm.isLocaleAvailable(locale))
98             setLocale(request, locale);
99
100         String JavaDoc fwdTo = dispatchVModuleElement(request, element, form, vm, locale);
101         if(fwdTo == null)
102         {
103             LoggingManager.log("Dispatcher wasn't able to dispatch element " + element, this);
104             return mapping.findForward(Constants.SCREEN_ERROR_UNKNOWNELEMENT);
105         }
106
107         return mapping.findForward(vm.getIdentification() + Constants.DEFAULT_SPACER + fwdTo);
108     }
109
110     /**
111      * Override just this method in your virtual module implementations ...
112      */

113     protected String JavaDoc dispatchVModuleElement(HttpServletRequest request,
114                                             String JavaDoc element,
115                                             ActionForm form,
116                                             VModule vm,
117                                             Locale JavaDoc locale)
118     {
119         return null;
120     }
121
122 }
123
124 // eof
125
Popular Tags