Denis Cucchietti
Denis Cucchietti

Reputation: 211

Return json view content without liferay theme

I'm currently using datatable in liferay portlet and i have to make ajax call and return a Json.

So in my controller i wrote :

@RenderMapping(params = "action=doAjaxSearch")
    public String ajaxSearch(RenderRequest request, RenderResponse response, @RequestParam int iDisplayStart,
            @RequestParam int iDisplayLength, @RequestParam String sEcho, Model model) {

        model.addAttribute("sEcho", sEcho);
        model.addAttribute("count", 20);

        return AJAX_RESULT;
    }

Where AJAX_RESULT is the view's name used to create my Json :

{ <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

"sEcho": , "iTotalRecords": ${count}, "iTotalDisplayRecords": ${count}, "aaData": [] }

Everything works fine but the response returned contains the json + liferay theme. I would like to just retrieve the jsp content.

Thanks in advance for your help guys.

Upvotes: 1

Views: 485

Answers (1)

Arnaud Charpentier
Arnaud Charpentier

Reputation: 101

While creating the URL, you add to mention the window state of your URL as Exclusive. eg.

<portlet:renderURL windowState="exclusive">
    <portlet:param name="action" value="doAjaxSearch" />
</portlet:renderURL>

Upvotes: 1

Related Questions