• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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: 17346
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic