RE: validation and DynaActionForm / concrete question
Hi man, Nice 2 find u on the list. As u have noticed...i am getting along with struts and trying To discover possibilities to do different kind of stuff that Can save me from writing code :-) Thanx 4 suggestion. marco -Original Message- From: Yves Sy [mailto:[EMAIL PROTECTED] Sent: 18 December 2003 04:50 To: 'Struts Users Mailing List' Subject: RE: validation and DynaActionForm / concrete question Hi Marco! I think using only one jsp wherein the number of form elements vary according to what you are doing can be considered as anti-pattern and is more of a JSP Model 1 design. The best way to make things work is to use a separate JSP for each form so that you can properly associate a separate ActionForm with each ActionMapping. If you wish to continue with the single jsp solution and still wish to use DynaValidatorForm, you can write your own Validator class and declare it in the validator-rules.xml. That way you can control how it will behave and validate the parameters... -Yves a.k.a. the witness to your long debates with Chad regarding morality and politcs :o) -Original Message- From: Marco Mistroni [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 1:30 AM To: 'Struts Users Mailing List' Subject: RE: validation and DynaActionForm / concrete question Hi Wendy, Only a little problem.. I haven't written any class for my DynaActionForm. Instead, I declare all the properties in the struts-config.xml Struts does all the rest But, anyway, can u give more details on ur solution to my problem? Regards marco -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: 17 December 2003 17:06 To: Struts Users Mailing List Subject: RE: validation and DynaActionForm / concrete question well i think the problem your having is because you're using a dispatch action so the form is mapped to the action and its set to validate. You can either separte yu dispatch actions into standard actions or hack it by having a single action that calls your dispatch action much like you were suggesting doing with jsp. What about LookupDispatchAction? It uses a request parameter to figure out which method to call. I use it with hidden form fields and a bit of JavaScript. In Marco's case, overriding the validate method might work. Only call super.validate() if all of the parameters are present. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
validation and DynaActionForm
Hi all, I am experiencing problems with DynaActionForm.. I have a DynaActionForm that contains 13 properties and A DispatchAction used calling different methods depending On the value of one parameter (named methodToCall). Now, when I enter the page for the first time the only request Parameter is 'methodToCall' since when I enter the page I need to Remove some values that were with session scope. The problem is that when I enter page for the first time I receive Following exception: 2/03 16:04:21:963 GMT] 51272c9d WebGroup E SRVE0026E: [Servlet Error]-[action]: java.lang.NullPointerException at org.apache.commons.validator.Validator.validate(Unknown Source) at org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm .java:303) at org.apache.struts.action.RequestProcessor.processValidate(RequestProcess or.java:893) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java: 247) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) Now, since it is a NullPointerException and it is raised by the validate, my assumption is that the DynaValidatorForm is trying to validate all the parameters in order to populate the Form, and since the only parameter in the request is methodToCall, it raises an exception. But, since I am no expert in DynaActionForm, can anyone help me out in Solving my problem? Thanx in advance and regards marco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validation and DynaActionForm
Hi Marco Perhaps try a none strust form element input type=hidden name=methodToCall value=foo rather than html:hidden property=methodToCall value=foo / also if possible in your situation html:form action=/myaction.do?methodToCall=foo Cheers Mark On 17 Dec 2003, at 16:10, Marco Mistroni wrote: Hi all, I am experiencing problems with DynaActionForm.. I have a DynaActionForm that contains 13 properties and A DispatchAction used calling different methods depending On the value of one parameter (named methodToCall). Now, when I enter the page for the first time the only request Parameter is 'methodToCall' since when I enter the page I need to Remove some values that were with session scope. The problem is that when I enter page for the first time I receive Following exception: 2/03 16:04:21:963 GMT] 51272c9d WebGroup E SRVE0026E: [Servlet Error]-[action]: java.lang.NullPointerException at org.apache.commons.validator.Validator.validate(Unknown Source) at org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorFor m .java:303) at org.apache.struts.action.RequestProcessor.processValidate(RequestProces s or.java:893) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java : 247) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) Now, since it is a NullPointerException and it is raised by the validate, my assumption is that the DynaValidatorForm is trying to validate all the parameters in order to populate the Form, and since the only parameter in the request is methodToCall, it raises an exception. But, since I am no expert in DynaActionForm, can anyone help me out in Solving my problem? Thanx in advance and regards marco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation and DynaActionForm
Hi Mark, Thanx.. but this A href=/myaction.do?methodToCall=foo../a is exactly what I am doing.. I am assuming that If validator is trying to validate all the Parameters I have no other choice than redirect straight to the Jsp... Thanx anyway and regards marco On 17 Dec 2003, at 16:10, Marco Mistroni wrote: Hi all, I am experiencing problems with DynaActionForm.. I have a DynaActionForm that contains 13 properties and A DispatchAction used calling different methods depending On the value of one parameter (named methodToCall). Now, when I enter the page for the first time the only request Parameter is 'methodToCall' since when I enter the page I need to Remove some values that were with session scope. The problem is that when I enter page for the first time I receive Following exception: 2/03 16:04:21:963 GMT] 51272c9d WebGroup E SRVE0026E: [Servlet Error]-[action]: java.lang.NullPointerException at org.apache.commons.validator.Validator.validate(Unknown Source) at org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorFor m .java:303) at org.apache.struts.action.RequestProcessor.processValidate(RequestProces s or.java:893) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java : 247) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) Now, since it is a NullPointerException and it is raised by the validate, my assumption is that the DynaValidatorForm is trying to validate all the parameters in order to populate the Form, and since the only parameter in the request is methodToCall, it raises an exception. But, since I am no expert in DynaActionForm, can anyone help me out in Solving my problem? Thanx in advance and regards marco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation and DynaActionForm / concrete question
Hi all, After struggling with my application, I have One question to ask. I have a DispatchAction class that handles my logic, and A DynaActionForm associated with it. The problem is that the jsp from which the request comes can Contain either 1, 2 parameters (out of 13 of DynaActionForm) or 13/13 parameters, since the page presents different information depending on which task I have to perform (either a search or an update or delete). Now, I keep on getting ValidationException when I have only 2 parameters In my DynaActionForm I have 9 Strings, 2 BigDecimal, 1 Short and 1 Timestamp. Am I receiving the exception (listed below) because Struts is trying to validate all the input parameters? If that is true, is It worth to use DynaActionForm when I don't have all the parameters supplied from jsp? Or, how do I have to proceed? Anyone has any suggestions? Thanx and regards Marco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: validation and DynaActionForm / concrete question
Hi marco well i think the problem your having is because you're using a dispatch action so the form is mapped to the action and its set to validate. You can either separte yu dispatch actions into standard actions or hack it by having a single action that calls your dispatch action much like you were suggesting doing with jsp. Cheers Mark On 17 Dec 2003, at 16:35, Marco Mistroni wrote: Hi all, After struggling with my application, I have One question to ask. I have a DispatchAction class that handles my logic, and A DynaActionForm associated with it. The problem is that the jsp from which the request comes can Contain either 1, 2 parameters (out of 13 of DynaActionForm) or 13/13 parameters, since the page presents different information depending on which task I have to perform (either a search or an update or delete). Now, I keep on getting ValidationException when I have only 2 parameters In my DynaActionForm I have 9 Strings, 2 BigDecimal, 1 Short and 1 Timestamp. Am I receiving the exception (listed below) because Struts is trying to validate all the input parameters? If that is true, is It worth to use DynaActionForm when I don't have all the parameters supplied from jsp? Or, how do I have to proceed? Anyone has any suggestions? Thanx and regards Marco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation and DynaActionForm / concrete question
well i think the problem your having is because you're using a dispatch action so the form is mapped to the action and its set to validate. You can either separte yu dispatch actions into standard actions or hack it by having a single action that calls your dispatch action much like you were suggesting doing with jsp. What about LookupDispatchAction? It uses a request parameter to figure out which method to call. I use it with hidden form fields and a bit of JavaScript. In Marco's case, overriding the validate method might work. Only call super.validate() if all of the parameters are present. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation and DynaActionForm / concrete question
Hi Wendy, Only a little problem.. I haven't written any class for my DynaActionForm. Instead, I declare all the properties in the struts-config.xml Struts does all the rest But, anyway, can u give more details on ur solution to my problem? Regards marco -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: 17 December 2003 17:06 To: Struts Users Mailing List Subject: RE: validation and DynaActionForm / concrete question well i think the problem your having is because you're using a dispatch action so the form is mapped to the action and its set to validate. You can either separte yu dispatch actions into standard actions or hack it by having a single action that calls your dispatch action much like you were suggesting doing with jsp. What about LookupDispatchAction? It uses a request parameter to figure out which method to call. I use it with hidden form fields and a bit of JavaScript. In Marco's case, overriding the validate method might work. Only call super.validate() if all of the parameters are present. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation and DynaActionForm / concrete question
Marco wrote: Only a little problem.. I haven't written any class for my DynaActionForm. Instead, I declare all the properties in the struts-config.xml That does not preclude you from writing a class-- Dyna forms just get you out of writing a bunch of get/set methods. You can still override 'validate' and 'reset' if you need to. I use DynaValidatorForm, and have a Java class for all but the most trivial forms. In struts-config, use your class name as the 'type' in the form-bean tag. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation and DynaActionForm / concrete question
Hi Marco! I think using only one jsp wherein the number of form elements vary according to what you are doing can be considered as anti-pattern and is more of a JSP Model 1 design. The best way to make things work is to use a separate JSP for each form so that you can properly associate a separate ActionForm with each ActionMapping. If you wish to continue with the single jsp solution and still wish to use DynaValidatorForm, you can write your own Validator class and declare it in the validator-rules.xml. That way you can control how it will behave and validate the parameters... -Yves a.k.a. the witness to your long debates with Chad regarding morality and politcs :o) -Original Message- From: Marco Mistroni [mailto:[EMAIL PROTECTED] Sent: Thursday, December 18, 2003 1:30 AM To: 'Struts Users Mailing List' Subject: RE: validation and DynaActionForm / concrete question Hi Wendy, Only a little problem.. I haven't written any class for my DynaActionForm. Instead, I declare all the properties in the struts-config.xml Struts does all the rest But, anyway, can u give more details on ur solution to my problem? Regards marco -Original Message- From: Wendy Smoak [mailto:[EMAIL PROTECTED] Sent: 17 December 2003 17:06 To: Struts Users Mailing List Subject: RE: validation and DynaActionForm / concrete question well i think the problem your having is because you're using a dispatch action so the form is mapped to the action and its set to validate. You can either separte yu dispatch actions into standard actions or hack it by having a single action that calls your dispatch action much like you were suggesting doing with jsp. What about LookupDispatchAction? It uses a request parameter to figure out which method to call. I use it with hidden form fields and a bit of JavaScript. In Marco's case, overriding the validate method might work. Only call super.validate() if all of the parameters are present. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]