dmitrievanthony
dmitrievanthony

Reputation: 1561

Refresh part of JSP page in Liferay MVC portlet

I need to refresh one table on a page without reloading the full page. Does anyone know good method for doing this?

I created separate a jspf page with one table, and rendered it by Ajax request <portlet:renderURL>, but the page wraps in the default liferay theme. Is there another way to get the page date without the theme?

<portlet:renderURL var="testURL">
    <portlet:param name="jspPage" value="/jspf/test.jspf" />
</portlet:renderURL>

<script>
$("#test-button").click(function() {
    $("#test-table").load("<%= testURL %>");
})
</script>

Upvotes: 4

Views: 6247

Answers (1)

Isa Hekmat
Isa Hekmat

Reputation: 758

To use Ajax in Liferay-MVC you should create a resourceURL Link and handle it in serveResource method in the Portlet Class.

<portlet:resourceURL var="testURL">
    <portlet:param name="pageAddress" value="/jspf/test.jspf" />
</portlet:resourceURL>

<script>
$("#test-button").click(function() {
    $("#test-table").load("<%= testURL %>");
})
</script>

then you should provide properly result in serveResource Method of your portlet class. in addition you can get your parameter(pageAddress) by using resourceRequest Object

String pageAddress = resourceRequest.getParameter("pageAddress");

Upvotes: 3

Related Questions