[Pfc-prolog-cvs] prolix/src/org/asturlinux/frade/prolix/web/actions SolutionAction.java,NONE,1.1 Loa
Status: Beta
Brought to you by:
ivanfrade
From: <iva...@us...> - 2003-07-14 17:16:50
|
Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions In directory sc8-pr-cvs1:/tmp/cvs-serv18040/src/org/asturlinux/frade/prolix/web/actions Modified Files: LoadConsultAction.java LoadProgramAction.java Added Files: SolutionAction.java Log Message: Added new actions and forms. Updated web navigation --- NEW FILE: SolutionAction.java --- package org.asturlinux.frade.prolix.web.actions; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import java.security.*; import org.apache.struts.action.*; import org.apache.struts.util.*; import org.asturlinux.frade.prolix.web.formbeans.*; import org.asturlinux.frade.prolix.ejb.interfaces.*; import org.asturlinux.frade.prolix.interpreter.exceptions.*; /** * @struts.action name="SolutionForm" * path="/actions/solution" * scope="request" * input="/consult.jsp" * validate="false" * parameter="" * * @struts.action-forward name="success" * path="/solutions.jsp" * */ public class SolutionAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ActionErrors errors = new ActionErrors(); return (mapping.findForward("success")); } } Index: LoadConsultAction.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions/LoadConsultAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LoadConsultAction.java 13 Jul 2003 21:38:50 -0000 1.2 --- LoadConsultAction.java 14 Jul 2003 17:16:47 -0000 1.3 *************** *** 9,16 **** import org.apache.struts.util.*; import org.asturlinux.frade.prolix.web.formbeans.*; ! /** ! * Action to load program ! * ! */ /** --- 9,14 ---- import org.apache.struts.util.*; import org.asturlinux.frade.prolix.web.formbeans.*; ! import org.asturlinux.frade.prolix.ejb.interfaces.*; ! import org.asturlinux.frade.prolix.interpreter.exceptions.*; /** *************** *** 46,70 **** // Take form bean atrributes ! //String consult = ((LoadProgramFormBean)form).getConsult(); ! String action = (String)request.getParameter("load"); ! if (action == null) { ! action = (String)request.getParameter("otherProgram"); ! if (action == null) ! { ! //FIXME Something is going BAD ! return (mapping.findForward("failure")); ! } ! else ! { ! return (mapping.findForward("otherProgram")); ! } } ! else { ! //FIXME here the code to load consult ! return (mapping.findForward("otherProgram")); } } } --- 44,90 ---- // Take form bean atrributes ! String consult = ((LoadConsultFormBean)form).getConsult(); ! ! //String action = (String)request.getParameter("load"); ! //if (action == null) ! // { ! // action = (String)request.getParameter("programAgain"); ! // if (action == null) ! // { ! // //FIXME Something is going BAD ! // return (mapping.findForward("failure")); ! // } ! // else // Wants to load another program ! // { ! // return (mapping.findForward("otherProgram")); ! // } ! // } ! // ! try { ! HttpSession session = request.getSession(); ! ProlixMain interpreter = (ProlixMain)session.getAttribute("interpreter"); ! interpreter.loadConsult(consult); } ! catch (SyntaxException se) { ! errors.add("consult",new ActionError("error.syntax.exception")); ! } ! catch (LexicalException le) ! { ! errors.add("consult",new ActionError("error.lexical.exception")); ! } ! catch (ProgramNotLoadedException pnle) ! { ! errors.add("consult",new ActionError("program.not.loaded")); } + if (!errors.isEmpty()) + { + saveErrors(request,errors); + return (mapping.findForward("failure")); + } + + return (mapping.findForward("success")); } } Index: LoadProgramAction.java =================================================================== RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/web/actions/LoadProgramAction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LoadProgramAction.java 13 Jul 2003 19:05:07 -0000 1.5 --- LoadProgramAction.java 14 Jul 2003 17:16:47 -0000 1.6 *************** *** 46,50 **** { HttpSession session = request.getSession(); ! ProlixMain interpreter = (ProlixMain)session.getAttribute("interpreter"); interpreter.loadProgram(program); } --- 46,50 ---- { HttpSession session = request.getSession(); ! ProlixMain interpreter = (ProlixMain)session.getAttribute("interpreterAt"); interpreter.loadProgram(program); } *************** *** 56,59 **** --- 56,64 ---- { errors.add("program",new ActionError("error.lexical.exception")); + } + catch (NullPointerException np) + { + errors.add("program", new ActionError("no.interpreter")); + System.out.println("Problems with interpreter"); } |