You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Paul Benedict (JIRA)" <ji...@apache.org> on 2007/08/29 05:29:34 UTC

[jira] Resolved: (STR-2020) Improve error detail when form validation fails from absent ActionServlet

     [ https://issues.apache.org/struts/browse/STR-2020?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Benedict resolved STR-2020.
--------------------------------

    Resolution: Fixed

> Improve error detail when form validation fails from absent ActionServlet
> -------------------------------------------------------------------------
>
>                 Key: STR-2020
>                 URL: https://issues.apache.org/struts/browse/STR-2020
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.1.0
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Ralf Hauser
>            Assignee: Paul Benedict
>            Priority: Minor
>             Fix For: 1.4.0
>
>
> In my multi-step form wizard, hidden form fields may be a bad idea for security
> reasons. Therefore, I keep a copy of the form in the session and incrementally
> add the values gathered from the browser.
> There arose even a scenario where it was advisable to set some values in that
> form even without first doing a PropertyUtils.copyProperties from a form coming
> from a browser. A subsequent .validate() then causes the above nullPointer
> exception.
> Suggestion: 
> When doing the 
>         ServletContext application = getServlet().getServletContext();
> in the ValidatorForm, first test whether the "getServlet()" really returns other
> than null and otherwise return a decent error message.
> I am not fully clear why the problem arises, but I guess that ValidatorForm()
> not having a constructor method is part of the reason for this.
> Anyway, I got it working by extending my form as follows:
> public class MyForm extends ValidatorForm
> 	public MyForm() {
> 		super();
> 	}
> 	public MyForm(ActionServlet servlet) {
> 		this();
> 		if (super.getServlet() == null) {
> 			if (servlet == null) {
> 				log.error("servlet == null");
> 			} else {
> 				super.setServlet(servlet);
> 				log.debug("set servlet: " + servlet);
> 			}
> 		} else {
> 			log.debug("super.getServlet(): " + super.getServlet());
> 		}
> when creating the form, I call it with 
> 	MyForm myForm = new MyForm(getServlet());

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.