1 package hero.struts.actions; 2 3 import java.io.IOException ; 4 import javax.servlet.ServletException ; 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpSession ; 7 import javax.servlet.http.HttpServletResponse ; 8 import org.apache.struts.action.ActionError; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionMapping; 12 import org.apache.struts.action.ActionForward; 13 14 import hero.interfaces.*; 15 16 17 23 public class EdgeAction extends AbstStrutsActionBase 24 { 25 26 public boolean authenticate(String username, String password) 27 { 28 return(true); 29 } 30 31 39 public ActionForward perform(ActionMapping mapping, ActionForm form, 40 HttpServletRequest request, HttpServletResponse response) throws IOException , ServletException 41 { 42 43 ActionForward actionForward = mapping.findForward(PROJECT); 44 ActionErrors errors = new ActionErrors(); 46 47 String action = request.getParameter("edgeAction"); 48 HttpSession session = request.getSession(); 49 String project = (String )session.getAttribute("projectname"); 50 51 try 52 { 53 hero.interfaces.ProjectSessionLocalHome projecth = (ProjectSessionLocalHome)hero.interfaces.ProjectSessionUtil.getLocalHome(); 54 hero.interfaces.ProjectSessionLocal projectsession = projecth.create(); 55 projectsession.initProject(project); 56 57 if (!isCancelled(request)) 58 { 59 if (action.equals("Edit")) 60 { 61 actionForward = mapping.findForward(PROJECT); 63 } 64 if (action.equals("Add")) 65 { 66 67 String in = request.getParameter("nodeIn"); 68 String out = request.getParameter("nodeOut"); 69 projectsession.addEdge(in, out); 70 request.getSession(true).setAttribute("project", projectsession); 71 72 actionForward = mapping.findForward(PROJECT); 74 } 75 if (action.equals("Delete")) 76 { 77 try { 78 String edgeName = request.getParameter("name"); 79 projectsession.deleteEdge(edgeName); 80 }catch(Exception e3){errors.add("edge_error", new ActionError("error.deleteedge.mismatch"));} 81 request.getSession(true).setAttribute("project", projectsession); 82 83 actionForward = mapping.findForward(PROJECT); 85 } 86 } 87 }catch(Exception e2){errors.add("edge_error", new ActionError("error.edge.mismatch"));} 90 91 if (!errors.empty()) { 92 saveErrors(request, errors); 93 } 94 95 return (actionForward); 97 } 98 99 } 100
| Popular Tags
|