• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

on submit, model object returning null

 
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.
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!