-1

I have two textboxes and one submit button in my program.when i provide some inputs and hit the submit button it works fine. When am not entering anything in the textboxes and hit the submit button , it is not working. It throwed the null pointer exception when form submit.

Error is below.

WicketMessage: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = form1]] threw an exception

    Root cause:

    java.lang.NullPointerException
    at com.usaa.application.pages.HomePage$3.onSubmit(HomePage.java:158)
    at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1518)
    at org.apache.wicket.markup.html.form.Form.process(Form.java:914)
    at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:876)

How to handle this error , please help me ...

Thanks, Kumar

rahul pasricha
  • 901
  • 1
  • 13
  • 32
user2949241
  • 79
  • 2
  • 2
  • 10

1 Answers1

1

Do this:

Textfield<String> tf1 = new TextField<String>("tf1");
tf1.setConvertEmptyInputStringToNull(false);
form.add(tf1);

The value from the textfield is now an empty string

Martin
  • 1,251
  • 11
  • 22