GeeCON Prague 2014*
The moose likes Spring and the fly likes on submit, model object returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "on submit, model object returning null" Watch "on submit, model object returning null" New topic
Author

on submit, model object returning null

vikas sharmaa
Ranch Hand

Joined: Jun 28, 2007
Posts: 191
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

Joined: Jun 28, 2007
Posts: 191
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

Joined: Jun 28, 2007
Posts: 191
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

Joined: Jun 28, 2007
Posts: 191
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

Joined: Jun 28, 2007
Posts: 191
at last, am able to resolve the issues!! i was not calling setValue() inside setAsText() method.
 
GeeCON Prague 2014
 
subject: on submit, model object returning null