If the JSR 286 has paved the way for the introduction of mechanisms AJAX within portlets via ResourceURL , there are actually rather few examples available on this Web.
This is mainly due to the ease of implementation of this solution. Proof of this is, this small example, not really really bad, which update a date, after a call server. Of course, it is forbidden to fully recharge the portal page. Development is done from the portlet template provided by the Liferay Plugin SDK 5.2.2 .
We start with the easy part, implementing GenericPortlet :
@ Override public void serveResource (ResourceRequest request, ResourceResponse response) throws PortletException, IOException {Date date = new Date (); request.setAttribute ("now", date); include (viewJSP, request, response);} @ Override public void doView (RenderRequest renderRequest, renderResponse renderResponse) throws IOException, PortletException {renderRequest.setAttribute ("now", "No set yet"); include (viewJSP, renderRequest, renderResponse);} The implementation remains extremely simplified:
. . . → Read more: AJAX and JSR 286


