The problem is that I have a dynamic form. I build it according with some data. I'd like to use validators method form within the validate() method in the action to avoid rewriting that code. I tryed to write something like
(new EmailValidator()).validate(email);
But it throws a NullPointerException. Probably it need a gigger environment...
can you help me?
2
votes
What triggered the NullPointerException?
- Steven Benitez
java.lang.NullPointerException com.opensymphony.xwork2.validator.validators.ValidatorSupport.getFieldValue(ValidatorSupport.java:180) com.opensymphony.xwork2.validator.validators.RegexFieldValidator.validate(RegexFieldValidator.java:60) com.stafnosusini.fidelity.actions.TestAction.execute(TestAction.java:16)
- s.susini
Action is the term in Struts to indicate something like a Servlet...
- s.susini
I think Quaternion was highlighting the lack of care taken in writing this post as opposed to really asking for the definition of an action :)
- Alex Barnes
2 Answers
0
votes
Which EmailValidator() you used in this case? In struts2, the validator is used base on the form textfield's field name. It will call the getter method of the field to be validate and apply the email regex to it. I suspect that it get null when calling to the getter method of the email field but get null, hence throw out the nullpointerexception when apply the regex on it.
cheers