• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic