S1: Problem overriding processValidate() from RequestProcessor
Hi to all. I'm working on a project using Struts 1.1 because those are client requirements. I override RequestProcessor and some of it's methods. like processRoles, processActionPerform, and so on. I want to implement a logic like Struts 2 Preparable interface, where if you implement in your Struts 2 Action you implement method prepare() that executes before an action method is called. I want to simulate that in Struts 1 so i created a PreparedForm where i define 2 methods signature: prepareBefore and PrepareAfter. prepareBefore will execute before action is called and prepareAfter until after action call. This is PreparedForm: public interface PreparedForm { public void prepareBefore(HttpServletRequest request); public void prepareAfter(HttpServletRequest request); } This is a form that implements PreparedForm: public class PaisForm extends DefaultActionForm implements PreparedForm { private String idpai; private String idmon; private String nombre; private String codigoNomina; public void prepareAfter(HttpServletRequest request) { //Do stuff after execute action method } public void prepareBefore(HttpServletRequest request) { //Do stuff before execute action method } ... So, i override processValidate to call here prepareAfter in case that form validation has errors, but maybe i didn't overrided well the method, this is my method: protected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException { boolean resValidacion = super.processValidate(request, response, form, mapping); //Si se implemento PreparedForm, se llama prepareAfter if (form instanceof PreparedForm !resValidacion) ((PreparedForm)form).prepareAfter(request); return resValidacion; } When i call an action and validate() in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); returns validation errors, it returns me directly to jsp and doesn't continue on the next lines and i don't know why. Thanks in advance. -- Oscar Calderón SCJP 6 http://javahowto.net
Re: S1: Problem overriding processValidate() from RequestProcessor
You only call prepareAfter if there aren't validation errors--if there are, it won't be called. On Fri, Sep 17, 2010 at 4:48 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all. I'm working on a project using Struts 1.1 because those are client requirements. I override RequestProcessor and some of it's methods. like processRoles, processActionPerform, and so on. I want to implement a logic like Struts 2 Preparable interface, where if you implement in your Struts 2 Action you implement method prepare() that executes before an action method is called. I want to simulate that in Struts 1 so i created a PreparedForm where i define 2 methods signature: prepareBefore and PrepareAfter. prepareBefore will execute before action is called and prepareAfter until after action call. This is PreparedForm: public interface PreparedForm { public void prepareBefore(HttpServletRequest request); public void prepareAfter(HttpServletRequest request); } This is a form that implements PreparedForm: public class PaisForm extends DefaultActionForm implements PreparedForm { private String idpai; private String idmon; private String nombre; private String codigoNomina; public void prepareAfter(HttpServletRequest request) { //Do stuff after execute action method } public void prepareBefore(HttpServletRequest request) { //Do stuff before execute action method } ... So, i override processValidate to call here prepareAfter in case that form validation has errors, but maybe i didn't overrided well the method, this is my method: protected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException { boolean resValidacion = super.processValidate(request, response, form, mapping); //Si se implemento PreparedForm, se llama prepareAfter if (form instanceof PreparedForm !resValidacion) ((PreparedForm)form).prepareAfter(request); return resValidacion; } When i call an action and validate() in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); returns validation errors, it returns me directly to jsp and doesn't continue on the next lines and i don't know why. Thanks in advance. -- Oscar Calderón SCJP 6 http://javahowto.net
Re: S1: Problem overriding processValidate() from RequestProcessor
But doesn't exist a way to do that? I mean, execute super.processValidate() and execute code after that? Because it will be useful to prepare stuff after you do something in the action, for example, insert something in the action and after prepare a list of items or something like that. 2010/9/17 Dave Newton davelnew...@gmail.com You only call prepareAfter if there aren't validation errors--if there are, it won't be called. On Fri, Sep 17, 2010 at 4:48 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all. I'm working on a project using Struts 1.1 because those are client requirements. I override RequestProcessor and some of it's methods. like processRoles, processActionPerform, and so on. I want to implement a logic like Struts 2 Preparable interface, where if you implement in your Struts 2 Action you implement method prepare() that executes before an action method is called. I want to simulate that in Struts 1 so i created a PreparedForm where i define 2 methods signature: prepareBefore and PrepareAfter. prepareBefore will execute before action is called and prepareAfter until after action call. This is PreparedForm: public interface PreparedForm { public void prepareBefore(HttpServletRequest request); public void prepareAfter(HttpServletRequest request); } This is a form that implements PreparedForm: public class PaisForm extends DefaultActionForm implements PreparedForm { private String idpai; private String idmon; private String nombre; private String codigoNomina; public void prepareAfter(HttpServletRequest request) { //Do stuff after execute action method } public void prepareBefore(HttpServletRequest request) { //Do stuff before execute action method } ... So, i override processValidate to call here prepareAfter in case that form validation has errors, but maybe i didn't overrided well the method, this is my method: protected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException { boolean resValidacion = super.processValidate(request, response, form, mapping); //Si se implemento PreparedForm, se llama prepareAfter if (form instanceof PreparedForm !resValidacion) ((PreparedForm)form).prepareAfter(request); return resValidacion; } When i call an action and validate() in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); returns validation errors, it returns me directly to jsp and doesn't continue on the next lines and i don't know why. Thanks in advance. -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net
Re: S1: Problem overriding processValidate() from RequestProcessor
... Of course you can execute code after that. *You're* executing code after that--but when there are validation errors the code you'll execute is the check to see if there were validation errors and the type check. On Fri, Sep 17, 2010 at 5:51 PM, Oscar oscar.kalde...@gmail.com wrote: But doesn't exist a way to do that? I mean, execute super.processValidate() and execute code after that? Because it will be useful to prepare stuff after you do something in the action, for example, insert something in the action and after prepare a list of items or something like that. 2010/9/17 Dave Newton davelnew...@gmail.com You only call prepareAfter if there aren't validation errors--if there are, it won't be called. On Fri, Sep 17, 2010 at 4:48 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all. I'm working on a project using Struts 1.1 because those are client requirements. I override RequestProcessor and some of it's methods. like processRoles, processActionPerform, and so on. I want to implement a logic like Struts 2 Preparable interface, where if you implement in your Struts 2 Action you implement method prepare() that executes before an action method is called. I want to simulate that in Struts 1 so i created a PreparedForm where i define 2 methods signature: prepareBefore and PrepareAfter. prepareBefore will execute before action is called and prepareAfter until after action call. This is PreparedForm: public interface PreparedForm { public void prepareBefore(HttpServletRequest request); public void prepareAfter(HttpServletRequest request); } This is a form that implements PreparedForm: public class PaisForm extends DefaultActionForm implements PreparedForm { private String idpai; private String idmon; private String nombre; private String codigoNomina; public void prepareAfter(HttpServletRequest request) { //Do stuff after execute action method } public void prepareBefore(HttpServletRequest request) { //Do stuff before execute action method } ... So, i override processValidate to call here prepareAfter in case that form validation has errors, but maybe i didn't overrided well the method, this is my method: protected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException { boolean resValidacion = super.processValidate(request, response, form, mapping); //Si se implemento PreparedForm, se llama prepareAfter if (form instanceof PreparedForm !resValidacion) ((PreparedForm)form).prepareAfter(request); return resValidacion; } When i call an action and validate() in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); returns validation errors, it returns me directly to jsp and doesn't continue on the next lines and i don't know why. Thanks in advance. -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net
Re: S1: Problem overriding processValidate() from RequestProcessor
But i understand that, if there are validation errors, in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); resValidacion will be false, but instead that looks like the execution breaks in that point and redirects to input 2010/9/17 Dave Newton davelnew...@gmail.com ... Of course you can execute code after that. *You're* executing code after that--but when there are validation errors the code you'll execute is the check to see if there were validation errors and the type check. On Fri, Sep 17, 2010 at 5:51 PM, Oscar oscar.kalde...@gmail.com wrote: But doesn't exist a way to do that? I mean, execute super.processValidate() and execute code after that? Because it will be useful to prepare stuff after you do something in the action, for example, insert something in the action and after prepare a list of items or something like that. 2010/9/17 Dave Newton davelnew...@gmail.com You only call prepareAfter if there aren't validation errors--if there are, it won't be called. On Fri, Sep 17, 2010 at 4:48 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all. I'm working on a project using Struts 1.1 because those are client requirements. I override RequestProcessor and some of it's methods. like processRoles, processActionPerform, and so on. I want to implement a logic like Struts 2 Preparable interface, where if you implement in your Struts 2 Action you implement method prepare() that executes before an action method is called. I want to simulate that in Struts 1 so i created a PreparedForm where i define 2 methods signature: prepareBefore and PrepareAfter. prepareBefore will execute before action is called and prepareAfter until after action call. This is PreparedForm: public interface PreparedForm { public void prepareBefore(HttpServletRequest request); public void prepareAfter(HttpServletRequest request); } This is a form that implements PreparedForm: public class PaisForm extends DefaultActionForm implements PreparedForm { private String idpai; private String idmon; private String nombre; private String codigoNomina; public void prepareAfter(HttpServletRequest request) { //Do stuff after execute action method } public void prepareBefore(HttpServletRequest request) { //Do stuff before execute action method } ... So, i override processValidate to call here prepareAfter in case that form validation has errors, but maybe i didn't overrided well the method, this is my method: protected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException { boolean resValidacion = super.processValidate(request, response, form, mapping); //Si se implemento PreparedForm, se llama prepareAfter if (form instanceof PreparedForm !resValidacion) ((PreparedForm)form).prepareAfter(request); return resValidacion; } When i call an action and validate() in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); returns validation errors, it returns me directly to jsp and doesn't continue on the next lines and i don't know why. Thanks in advance. -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net
Re: S1: Problem overriding processValidate() from RequestProcessor
I'm skeptical--does the superclass throw an exception? On Fri, Sep 17, 2010 at 6:26 PM, Oscar oscar.kalde...@gmail.com wrote: But i understand that, if there are validation errors, in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); resValidacion will be false, but instead that looks like the execution breaks in that point and redirects to input 2010/9/17 Dave Newton davelnew...@gmail.com ... Of course you can execute code after that. *You're* executing code after that--but when there are validation errors the code you'll execute is the check to see if there were validation errors and the type check. On Fri, Sep 17, 2010 at 5:51 PM, Oscar oscar.kalde...@gmail.com wrote: But doesn't exist a way to do that? I mean, execute super.processValidate() and execute code after that? Because it will be useful to prepare stuff after you do something in the action, for example, insert something in the action and after prepare a list of items or something like that. 2010/9/17 Dave Newton davelnew...@gmail.com You only call prepareAfter if there aren't validation errors--if there are, it won't be called. On Fri, Sep 17, 2010 at 4:48 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all. I'm working on a project using Struts 1.1 because those are client requirements. I override RequestProcessor and some of it's methods. like processRoles, processActionPerform, and so on. I want to implement a logic like Struts 2 Preparable interface, where if you implement in your Struts 2 Action you implement method prepare() that executes before an action method is called. I want to simulate that in Struts 1 so i created a PreparedForm where i define 2 methods signature: prepareBefore and PrepareAfter. prepareBefore will execute before action is called and prepareAfter until after action call. This is PreparedForm: public interface PreparedForm { public void prepareBefore(HttpServletRequest request); public void prepareAfter(HttpServletRequest request); } This is a form that implements PreparedForm: public class PaisForm extends DefaultActionForm implements PreparedForm { private String idpai; private String idmon; private String nombre; private String codigoNomina; public void prepareAfter(HttpServletRequest request) { //Do stuff after execute action method } public void prepareBefore(HttpServletRequest request) { //Do stuff before execute action method } ... So, i override processValidate to call here prepareAfter in case that form validation has errors, but maybe i didn't overrided well the method, this is my method: protected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException { boolean resValidacion = super.processValidate(request, response, form, mapping); //Si se implemento PreparedForm, se llama prepareAfter if (form instanceof PreparedForm !resValidacion) ((PreparedForm)form).prepareAfter(request); return resValidacion; } When i call an action and validate() in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); returns validation errors, it returns me directly to jsp and doesn't continue on the next lines and i don't know why. Thanks in advance. -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net
Re: S1: Problem overriding processValidate() from RequestProcessor
No, i was looking in the stack trace but there's no exception, just redirects to input page. 2010/9/17 Dave Newton davelnew...@gmail.com I'm skeptical--does the superclass throw an exception? On Fri, Sep 17, 2010 at 6:26 PM, Oscar oscar.kalde...@gmail.com wrote: But i understand that, if there are validation errors, in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); resValidacion will be false, but instead that looks like the execution breaks in that point and redirects to input 2010/9/17 Dave Newton davelnew...@gmail.com ... Of course you can execute code after that. *You're* executing code after that--but when there are validation errors the code you'll execute is the check to see if there were validation errors and the type check. On Fri, Sep 17, 2010 at 5:51 PM, Oscar oscar.kalde...@gmail.com wrote: But doesn't exist a way to do that? I mean, execute super.processValidate() and execute code after that? Because it will be useful to prepare stuff after you do something in the action, for example, insert something in the action and after prepare a list of items or something like that. 2010/9/17 Dave Newton davelnew...@gmail.com You only call prepareAfter if there aren't validation errors--if there are, it won't be called. On Fri, Sep 17, 2010 at 4:48 PM, Oscar oscar.kalde...@gmail.com wrote: Hi to all. I'm working on a project using Struts 1.1 because those are client requirements. I override RequestProcessor and some of it's methods. like processRoles, processActionPerform, and so on. I want to implement a logic like Struts 2 Preparable interface, where if you implement in your Struts 2 Action you implement method prepare() that executes before an action method is called. I want to simulate that in Struts 1 so i created a PreparedForm where i define 2 methods signature: prepareBefore and PrepareAfter. prepareBefore will execute before action is called and prepareAfter until after action call. This is PreparedForm: public interface PreparedForm { public void prepareBefore(HttpServletRequest request); public void prepareAfter(HttpServletRequest request); } This is a form that implements PreparedForm: public class PaisForm extends DefaultActionForm implements PreparedForm { private String idpai; private String idmon; private String nombre; private String codigoNomina; public void prepareAfter(HttpServletRequest request) { //Do stuff after execute action method } public void prepareBefore(HttpServletRequest request) { //Do stuff before execute action method } ... So, i override processValidate to call here prepareAfter in case that form validation has errors, but maybe i didn't overrided well the method, this is my method: protected boolean processValidate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ActionForm form, ActionMapping mapping) throws java.io.IOException, javax.servlet.ServletException { boolean resValidacion = super.processValidate(request, response, form, mapping); //Si se implemento PreparedForm, se llama prepareAfter if (form instanceof PreparedForm !resValidacion) ((PreparedForm)form).prepareAfter(request); return resValidacion; } When i call an action and validate() in this line: boolean resValidacion = super.processValidate(request, response, form, mapping); returns validation errors, it returns me directly to jsp and doesn't continue on the next lines and i don't know why. Thanks in advance. -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net -- Oscar Calderón SCJP 6 http://javahowto.net