Example usage for org.springframework.http.converter.json MappingJacksonValue MappingJacksonValue

List of usage examples for org.springframework.http.converter.json MappingJacksonValue MappingJacksonValue

Introduction

In this page you can find the example usage for org.springframework.http.converter.json MappingJacksonValue MappingJacksonValue.

Prototype

public MappingJacksonValue(Object value) 

Source Link

Document

Create a new instance wrapping the given POJO to be serialized.

Usage

From source file:edu.usc.lunchnlearn.elasticsearch.controller.SuggestController.java

@RequestMapping(value = "/suggest/{partial}", method = RequestMethod.GET, headers = "Accept=application/json", params = {
        "callback" })
public MappingJacksonValue listData(@PathVariable("partial") String partial,
        @RequestParam("callback") String callback) {
    MappingJacksonValue value = new MappingJacksonValue(searchSuggestService.getSuggestions(partial));
    value.setJsonpFunction(callback);//  w w  w. ja  v a  2s. c o m
    return value;
    //        return searchSuggestService.getSuggestions(partial);
}

From source file:edu.usc.lunchnlearn.elasticsearch.controller.SimpleSearchApiController.java

@RequestMapping(value = "/api/search", method = RequestMethod.GET, params = { "searchQuery", "currentPage",
        "callback" })
public MappingJacksonValue search(@RequestParam("searchQuery") String searchQuery,
        @RequestParam("currentPage") int currentPage, @RequestParam("callback") String callback) {
    MappingJacksonValue value = new MappingJacksonValue(searchService.findAll(searchQuery, currentPage));
    value.setJsonpFunction(callback);/*from   www  .jav a 2 s .  c  om*/
    return value;
}

From source file:webFramework.MappingJackson2PrettyJsonView.java

@Override
protected Object filterAndWrapModel(Map<String, Object> model, HttpServletRequest request) {
    Object value = super.filterAndWrapModel(model, request);
    String jsonpParameterValue = getJsonpParameterValue(request);
    if (jsonpParameterValue != null) {
        if (value instanceof MappingJacksonValue) {
            ((MappingJacksonValue) value).setJsonpFunction(jsonpParameterValue);
        } else {/*from   ww w . j  a v a  2  s . c  o m*/
            MappingJacksonValue container = new MappingJacksonValue(value);
            container.setJsonpFunction(jsonpParameterValue);
            value = container;
        }
    }
    return value;
}