@RequestMapping(method = RequestMethod.POST, params = "action=movePortletAjax")
    public ModelAndView movePortletAjax(
            HttpServletRequest request,
            HttpServletResponse response,
            @RequestParam String sourceId,
            @RequestParam String previousNodeId,
            @RequestParam String nextNodeId) {
        final Locale locale = RequestContextUtils.getLocale(request);
        boolean success = false;
        if (StringUtils.isNotBlank(nextNodeId)) {
            success = moveElementInternal(request, sourceId, nextNodeId, "insertBefore");
        } else {
            success = moveElementInternal(request, sourceId, previousNodeId, "appendAfter");
        }
        if (success) {
            return new ModelAndView(
                    "jsonView",
                    Collections.singletonMap(
                            "response",
                            getMessage(
                                    "success.move.element", "Element moved successfully", locale)));
        } else {
            response.setStatus(HttpServletResponse.SC_FORBIDDEN);
            return new ModelAndView(
                    "jsonView",
                    Collections.singletonMap(
                            "response",
                            getMessage("error.move.element", "Error moving element.", locale)));
        }
    }
@ RequestMapping ( method = RequestMethod . POST , params = "action=movePortletAjax" ) public ModelAndView movePortletAjax ( HttpServletRequest request , HttpServletResponse response , @ RequestParam String sourceId , @ RequestParam String previousNodeId , @ RequestParam String nextNodeId ) { final Locale locale = RequestContextUtils . getLocale ( request ) ; boolean success = false ; if ( StringUtils . isNotBlank ( nextNodeId ) ) { success = moveElementInternal ( request , sourceId , nextNodeId , "insertBefore" ) ; } else { success = moveElementInternal ( request , sourceId , previousNodeId , "appendAfter" ) ; } if ( success ) { return new ModelAndView ( "jsonView" , Collections . singletonMap ( "response" , getMessage ( "success.move.element" , "Element moved successfully" , locale ) ) ) ; } else { response . setStatus ( HttpServletResponse . SC_FORBIDDEN ) ; return new ModelAndView ( "jsonView" , Collections . singletonMap ( "response" , getMessage ( "error.move.element" , "Error moving element." , locale ) ) ) ; } }
Moves the portlet either before nextNodeId or after previousNodeId as appropriate.

@param request HttpRequest
@param response HttpResponse
@param sourceId nodeId to move
@param previousNodeId if nextNodeId is not blank, moves portlet to end of list previousNodeId
is in
@param nextNodeId nodeId to insert sourceId before.
@return JSON containing a success message or an error message