Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9223061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:59:01+00:00 2026-06-18T03:59:01+00:00

I am specifying the property editors for my controller as : @InitBinder protected void

  • 0

I am specifying the property editors for my controller as :

@InitBinder
    protected void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
        CustomDateEditor editor = new CustomDateEditor(dateFormat, true);
        binder.registerCustomEditor(Date.class, editor);
    }

which work fine until I call the following method in an AJAX call.

@RequestMapping(value = "searchCriteria", method = RequestMethod.GET)
    public @ResponseBody Set<SearchCriteria> loadSearchCriterias(){
        // call service method to load criterias
        Set<SearchCriteria> criterias = new HashSet<SearchCriteria>();
        SearchCriteria sampleCriteria = new SearchCriteria();
        sampleCriteria.setStartDate(new Date());
                criterias.add(sampleCriteria);
        return criterias;
         }

In this case, the due date in SearchCriteria is not being converted to the proper format by the custom property editor. How can I make property editors to be applied even when I am returning an object through an AJAX call ?

public class SearchCriteria{
    Date startDate;
    String name;
    // getter setters
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:59:03+00:00Added an answer on June 18, 2026 at 3:59 am

    I don’t think it is possible to apply property editor for the returned values. Spring has a converter mechanism for it.

    If you returning json and if you have Jackson in your classpath then spring will use it to convert the object to response string.
    If you returning xml and if you have JAXB in your classpath then spring will use it to convert the object to response string.

    If you are using Jackson library with spring then you need to tell jackson how you want to serialize the field by using serializer.

    Ex:

    public class DateTimeSerializer extends JsonSerializer<Date> {
    
        @Override
        public void serialize(Date value, JsonGenerator jgen,
                SerializerProvider provider) throws IOException,
                JsonProcessingException {
            if (value != null) {
                SimpleDateFormat f = new SimpleDateFormat(format);
                jgen.writeString(f.format(value));
            }
        }
    
    }
    

    Then annotate your field like

    @JsonSerialize(using = DateTimeSerializer.class)
    private Date createdDate;
    

    If you want to use this globally you can try the mechanism explained here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When is the Path= xaml syntax required when specifying a binding to a property?
Is there a way to animate in Jquery without specifying every property? Lets, say:
In PowerShell, how do you get an object's property value by specifying its name
I have a properties file that contains a property specifying the URL of a
with google maps API v2 we can maximize the infowindow by specifying maxTitle property.
How can I locate an element just by specifying the text property, whether its
I'd like to make this function more generic by specifying the property of Foo
By specifying -lib foo.jar to ant I get the behaviour that the classes in
I have requirement of specifying web part connections in onet.xml. So when site is
I have three tables specifying important columns below Users(Id, username) Groups(Id, groupname, creator) (creator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.