2

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?

s.susini
  • 601
  • 1
  • 9
  • 18
  • What triggered the NullPointerException? – Steven Benitez Dec 22 '10 at 15:34
  • 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 Dec 22 '10 at 17:33
  • Action is the term in Struts to indicate something like a Servlet... – s.susini Dec 23 '10 at 01:03
  • 2
    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 Dec 23 '10 at 11:10

2 Answers2

0

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

Vince
  • 125
  • 1
  • 6
0

Actually I came across a same problem today. I'm sure that my getter method for that field doesn't returns null.(Actually I tried printing the value returned by getter method.It works fine). So where else could the problem be?.