• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Problem in saving the form

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am trying to create a form which will add the user record in the database. When i click the submit button, it looks like that form is not submitted. In the debug mode, its not going inside onSubmit. I am not seeing any exception.

On the form level, there is an input field "status", and on the bean side i have an enum Status. So how to map this? How to do mapping for this kind of thing. I suspect form save problem is because of this.

So i have two questions here:
1. how to map a form field to bean's enum.
2. any reason onSubmit is not called?

Can you guys give me an example how to write custom property editor for enum, how to register with binder and how to specify this form field value should map to bean's enum.


Thank you very much.
 
Faraz Ali
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am now able to save the form with string, date and enum values. There is one problem while saving enums, instead of the actual enum value, its saving the index value of enums. I also tried creating a custom property editor for enum, but its storing 0, 1, 2 etc, not storing the real string values which i want to save.

See my code below:










So above is all the code i am having. No matter i use enum property editor or not, it always inserts index values instead of text.


Thanks,
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at your code, it looks like that the Title is the enum. If yes, than use the @Enumerated annotation with the Title field as below:



Hopes this will help.

Thanks,
 
Faraz Ali
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

yes its working properly now.
 
You have to be odd to be #1 - Seuss. An odd little ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic