• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

on submit, model object returning null

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Spring 3.0.

I am setting "position" attribute as model object. but, property of position model objects are returning null on submit. how to resolve it?

Please find below the code, with comments:

Model class:


Controller class:


jsp page:

 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i also tried to add attributes of "position" into model object as follows:


and added the below line in jsp


but this time i am getting below error:



please help.
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess, i required Built-in PropertyEditor implementations to resolve the issue. i am going through the article on spring website http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html

will get back to here, if not able to resolve the problem.
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After going through many tutorials on net, i modified my controller class by adding InitBinder as shown below:

Controller class:



i also created UserEditor and BoardEditor classes under the same directory where User and Board class resides. and implemented getAsText and setAsText methods as shown below for UserEditor class:



my jsp code, as it is:



the value in path="user" is showing correctly on click of submit button in the setAsText() method of UserEditor class... but this value is not getting copied to model object of the onSubmit method call in controller class...

please help me in resolving it. Thank you.
 
vikas sharmaa
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at last, am able to resolve the issues!! i was not calling setValue() inside setAsText() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic