KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > struts > actions > InitialAction


1 package hero.struts.actions;
2
3 import java.io.IOException JavaDoc;
4 import javax.servlet.ServletException JavaDoc;
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7 import org.apache.struts.action.ActionErrors;
8 import org.apache.struts.action.ActionForm;
9 import org.apache.struts.action.ActionMapping;
10 import org.apache.struts.action.ActionForward;
11
12 import java.util.*;
13
14 import hero.interfaces.*;
15
16 /**
17  * <strong>EdgeAction</strong>
18  * Action that allows the user to add a new edge in the current project
19  *
20  *@author Miguel Valdes Faura
21  */

22 public class InitialAction extends AbstStrutsActionBase
23 {
24
25   public boolean authenticate(String JavaDoc username, String JavaDoc password)
26   {
27     return(true);
28   }
29
30     /**
31      * @param mapping The ActionMapping used to select this instance
32      * @param actionForm The optional AbstActionFormBase bean for this request (if any)
33      * @param request The HTTP request we are processing
34      * @param response The HTTP response we are creating
35      * @exception IOException if an input/output error occurs
36      * @exception ServletException if a servlet exception occurs
37      */

38     public ActionForward perform(ActionMapping mapping, ActionForm form,
39         HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws IOException JavaDoc, ServletException JavaDoc
40     {
41
42         ActionForward actionForward = mapping.findForward(INITIAL);
43         // Create the container for any errors that occur
44
ActionErrors errors = new ActionErrors();
45
46     try
47     {
48         hero.interfaces.AllProjectsSessionLocalHome projecth = (AllProjectsSessionLocalHome)hero.interfaces.AllProjectsSessionUtil.getLocalHome();
49             
50         hero.interfaces.AllProjectsSessionLocal projectl = projecth.create();
51         
52         Vector projects = new Vector((Collection)projectl.getProjects());
53         request.getSession(true).setAttribute("allprojects",projects);
54         request.getSession(true).setAttribute("wsname",null);
55         
56     }catch(Exception JavaDoc e){e.printStackTrace();throw new ServletException JavaDoc();};
57     
58     if (!errors.empty()) {
59         saveErrors(request, errors);
60         }
61     
62     // Forward control to the appropriate URI as determined by the action.
63
return (actionForward);
64     }
65     
66 }
67
Popular Tags