• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getAsText() not called Spring MVC PropertyEditorSupport AJAX

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

I have a enum property editor like:


I have registered it in my Spring MVC controller like:


Whenever i make an AJAX call to this controller the setAsText() method gets called and works fine. The problem is with getAsText() method which is not getting called when the server responds with a JSON string.

Please guide. What am i missing?


Regards,
Jagpreet Singh
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not knowing for sure. My guess would be that PropertyEditors in Spring are mainly if only used to convert String to some format. But not the other way around. So I think the incoming String is being converted to the type, but it won't try to use the PropertyEditor on the way out. For that I would think you need to use a Convertor in Jackson. Meaning I think it is Jackson that doesn't try to convert it from a string. Not Spring at all.

Just a guess, but try making a Jackson converter.

Something like this

https://github.com/aws/aws-sdk-java/blob/master/src/main/java/com/amazonaws/services/simpleworkflow/flow/JsonDataConverter.java

Actually, looking at some code I had I think I mean a Serializer not a converter in Jackson

JsonSerializer

Mark
 
Juggy Obhi
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks Mark. Words of wisdom. big help


Regards,
Jagpreet Singh
reply
    Bookmark Topic Watch Topic
  • New Topic