01: package hero.struts.actions;
02:
03: import java.io.IOException;
04: import javax.servlet.ServletException;
05: import javax.servlet.http.HttpServletRequest;
06: import javax.servlet.http.HttpServletResponse;
07: import org.apache.struts.action.ActionErrors;
08: import org.apache.struts.action.ActionForm;
09: 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: public boolean authenticate(String username, String password) {
25: return (true);
26: }
27:
28: /**
29: * @param mapping The ActionMapping used to select this instance
30: * @param actionForm The optional AbstActionFormBase bean for this request (if any)
31: * @param request The HTTP request we are processing
32: * @param response The HTTP response we are creating
33: * @exception IOException if an input/output error occurs
34: * @exception ServletException if a servlet exception occurs
35: */
36: public ActionForward perform(ActionMapping mapping,
37: ActionForm form, HttpServletRequest request,
38: HttpServletResponse response) throws IOException,
39: ServletException {
40:
41: ActionForward actionForward = mapping.findForward(INITIAL);
42: // Create the container for any errors that occur
43: ActionErrors errors = new ActionErrors();
44:
45: try {
46: hero.interfaces.AllProjectsSessionLocalHome projecth = (AllProjectsSessionLocalHome) hero.interfaces.AllProjectsSessionUtil
47: .getLocalHome();
48:
49: hero.interfaces.AllProjectsSessionLocal projectl = projecth
50: .create();
51:
52: Vector projects = new Vector((Collection) projectl
53: .getProjects());
54: request.getSession(true).setAttribute("allprojects",
55: projects);
56: request.getSession(true).setAttribute("wsname", null);
57:
58: } catch (Exception e) {
59: e.printStackTrace();
60: throw new ServletException();
61: }
62: ;
63:
64: if (!errors.empty()) {
65: saveErrors(request, errors);
66: }
67:
68: // Forward control to the appropriate URI as determined by the action.
69: return (actionForward);
70: }
71:
72: }
|