aspose file tools*
The moose likes Spring and the fly likes getAsText() not called Spring MVC PropertyEditorSupport AJAX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "getAsText() not called Spring MVC PropertyEditorSupport AJAX" Watch "getAsText() not called Spring MVC PropertyEditorSupport AJAX" New topic
Author

getAsText() not called Spring MVC PropertyEditorSupport AJAX

Juggy Obhi
Ranch Hand

Joined: Jul 02, 2007
Posts: 51
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


It does not matter how many times you fall,what matters is how many times you stand back.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Juggy Obhi
Ranch Hand

Joined: Jul 02, 2007
Posts: 51
Many thanks Mark. Words of wisdom. big help


Regards,
Jagpreet Singh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getAsText() not called Spring MVC PropertyEditorSupport AJAX