@ RequestMapping ( method = RequestMethod . POST , params = "action=removeElement" ) public ModelAndView removeElement ( HttpServletRequest request , HttpServletResponse response ) throws IOException { IUserInstance ui = userInstanceManager . getUserInstance ( request ) ; IPerson per = getPerson ( ui , response ) ; UserPreferencesManager upm = ( UserPreferencesManager ) ui . getPreferencesManager ( ) ; IUserLayoutManager ulm = upm . getUserLayoutManager ( ) ; try { // Delete the requested element node. This code is the same for // all node types, so we can just have a generic action. String elementId = request . getParameter ( "elementID" ) ; if ( ! ulm . deleteNode ( elementId ) ) { logger . info ( "Failed to remove element ID {} from layout root folder ID {}, delete node returned false" , elementId , ulm . getRootFolderId ( ) ) ; response . sendError ( HttpServletResponse . SC_FORBIDDEN ) ; return new ModelAndView ( "jsonView" , Collections . singletonMap ( "error" , getMessage ( "error.element.update" , "Unable to update element" , RequestContextUtils . getLocale ( request ) ) ) ) ; } ulm . saveUserLayout ( ) ; return new ModelAndView ( "jsonView" , Collections . emptyMap ( ) ) ; } catch ( PortalException e ) { return handlePersistError ( request , response , e ) ; } }
Remove an element from the layout .