Java Code Examples for javax.portlet.ActionResponse#setPortletMode()
The following examples show how to use
javax.portlet.ActionResponse#setPortletMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreferencesActionController.java From portals-pluto with Apache License 2.0 | 6 votes |
@ActionMethod(portletName = "portlet1", actionName = "submitPreferences") @CsrfProtected public void submitPreferences(ActionRequest actionRequest, ActionResponse actionResponse) { ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale()); models.put("preferences", new Preferences(datePattern)); Set<ParamError> bindingErrors = bindingResult.getAllErrors(); if (bindingErrors.isEmpty()) { try { portletPreferences.setValue("datePattern", datePattern); portletPreferences.store(); actionResponse.setPortletMode(PortletMode.VIEW); actionResponse.setWindowState(WindowState.NORMAL); models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully")); } catch (Exception e) { models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred")); logger.error(e.getMessage(), e); } } }
Example 2
Source File: PreferencesActionController.java From portals-pluto with Apache License 2.0 | 6 votes |
@ActionMethod(portletName = "portlet1", actionName = "submitPreferences") @CsrfProtected public void submitPreferences(ActionRequest actionRequest, ActionResponse actionResponse) { ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale()); models.put("preferences", new Preferences(datePattern)); Set<ParamError> bindingErrors = bindingResult.getAllErrors(); if (bindingErrors.isEmpty()) { try { portletPreferences.setValue("datePattern", datePattern); portletPreferences.store(); actionResponse.setPortletMode(PortletMode.VIEW); actionResponse.setWindowState(WindowState.NORMAL); models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully")); } catch (Exception e) { models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred")); logger.error(e.getMessage(), e); } } }
Example 3
Source File: PortletIFrame.java From sakai with Educational Community License v2.0 | 5 votes |
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { // log.info("==== processAction called ===="); PortletSession pSession = request.getPortletSession(true); // Our first challenge is to figure out which action we want to take // The view selects the "next action" either as a URL parameter // or as a hidden field in the POST data - we check both String doCancel = request.getParameter("sakai.cancel"); String doUpdate = request.getParameter("sakai.update"); // Our next challenge is to pick which action the previous view // has told us to do. Note that the view may place several actions // on the screen and the user may have an option to pick between // them. Make sure we handle the "no action" fall-through. pSession.removeAttribute("error.message"); if ( doCancel != null ) { response.setPortletMode(PortletMode.VIEW); } else if ( doUpdate != null ) { processActionEdit(request, response); } else { // log.info("Unknown action"); response.setPortletMode(PortletMode.VIEW); } // log.info("==== End of ProcessAction ===="); }
Example 4
Source File: SakaiIFrame.java From sakai with Educational Community License v2.0 | 5 votes |
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { log.debug("==== processAction called ===="); PortletSession pSession = request.getPortletSession(true); // Our first challenge is to figure out which action we want to take // The view selects the "next action" either as a URL parameter // or as a hidden field in the POST data - we check both String doCancel = request.getParameter("sakai.cancel"); String doUpdate = request.getParameter("sakai.update"); // Our next challenge is to pick which action the previous view // has told us to do. Note that the view may place several actions // on the screen and the user may have an option to pick between // them. Make sure we handle the "no action" fall-through. pSession.removeAttribute("error.message"); if ( doCancel != null ) { response.setPortletMode(PortletMode.VIEW); } else if ( doUpdate != null ) { processActionEdit(request, response); } else { log.debug("Unknown action"); response.setPortletMode(PortletMode.VIEW); } log.debug("==== End of ProcessAction ===="); }
Example 5
Source File: IMSBLTIPortlet.java From sakai with Educational Community License v2.0 | 5 votes |
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { log.debug("==== processAction called ===="); String action = request.getParameter("sakai.action"); log.debug("sakai.action = {}", action); PortletSession pSession = request.getPortletSession(true); // Clear before Action clearErrorMessage(request); String view = (String) pSession.getAttribute("sakai.view"); log.debug("sakai.view={}", view); if ( action == null ) { // Do nothing } else if ( action.equals("main") ) { response.setPortletMode(PortletMode.VIEW); } else if ( action.equals("edit") ) { pSession.setAttribute("sakai.view", "edit"); } else if ( action.equals("edit.reset") ) { pSession.setAttribute("sakai.view","edit.reset"); } else if (action.equals("edit.setup")){ pSession.setAttribute("sakai.view","edit.setup"); } else if ( action.equals("edit.clear") ) { clearSession(request); response.setPortletMode(PortletMode.VIEW); pSession.setAttribute("sakai.view", "main"); } else if ( action.equals("edit.do.reset") ) { processActionReset(action,request, response); } else if ( action.equals("edit.save") ) { processActionSave(action,request, response); } log.debug("==== End of ProcessAction ===="); }
Example 6
Source File: PreferencesActionController.java From portals-pluto with Apache License 2.0 | 5 votes |
@ActionMethod(portletName = "portlet1", actionName = "reset") @ValidateOnExecution(type = ExecutableType.NONE) @CsrfProtected public void resetPreferences(ActionRequest actionRequest, ActionResponse actionResponse) { ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale()); try { Enumeration<String> preferenceNames = portletPreferences.getNames(); while (preferenceNames.hasMoreElements()) { String preferenceName = preferenceNames.nextElement(); if (!portletPreferences.isReadOnly(preferenceName)) { portletPreferences.reset(preferenceName); } } portletPreferences.store(); actionResponse.setPortletMode(PortletMode.VIEW); actionResponse.setWindowState(WindowState.NORMAL); models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully")); } catch (Exception e) { models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred")); logger.error(e.getMessage(), e); } }
Example 7
Source File: PreferencesActionController.java From portals-pluto with Apache License 2.0 | 5 votes |
@ActionMethod(portletName = "portlet1", actionName = "reset") @ValidateOnExecution(type = ExecutableType.NONE) @CsrfProtected public void resetPreferences(ActionRequest actionRequest, ActionResponse actionResponse) { ResourceBundle resourceBundle = portletConfig.getResourceBundle(actionRequest.getLocale()); try { Enumeration<String> preferenceNames = portletPreferences.getNames(); while (preferenceNames.hasMoreElements()) { String preferenceName = preferenceNames.nextElement(); if (!portletPreferences.isReadOnly(preferenceName)) { portletPreferences.reset(preferenceName); } } portletPreferences.store(); actionResponse.setPortletMode(PortletMode.VIEW); actionResponse.setWindowState(WindowState.NORMAL); models.put("globalInfoMessage", resourceBundle.getString("your-request-processed-successfully")); } catch (Exception e) { models.put("globalErrorMessage", resourceBundle.getString("an-unexpected-error-occurred")); logger.error(e.getMessage(), e); } }
Example 8
Source File: PortletIFrame.java From sakai with Educational Community License v2.0 | 5 votes |
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { // log.info("==== processAction called ===="); PortletSession pSession = request.getPortletSession(true); // Our first challenge is to figure out which action we want to take // The view selects the "next action" either as a URL parameter // or as a hidden field in the POST data - we check both String doCancel = request.getParameter("sakai.cancel"); String doUpdate = request.getParameter("sakai.update"); // Our next challenge is to pick which action the previous view // has told us to do. Note that the view may place several actions // on the screen and the user may have an option to pick between // them. Make sure we handle the "no action" fall-through. pSession.removeAttribute("error.message"); if ( doCancel != null ) { response.setPortletMode(PortletMode.VIEW); } else if ( doUpdate != null ) { processActionEdit(request, response); } else { // log.info("Unknown action"); response.setPortletMode(PortletMode.VIEW); } // log.info("==== End of ProcessAction ===="); }
Example 9
Source File: SakaiIFrame.java From sakai with Educational Community License v2.0 | 5 votes |
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { log.debug("==== processAction called ===="); PortletSession pSession = request.getPortletSession(true); // Our first challenge is to figure out which action we want to take // The view selects the "next action" either as a URL parameter // or as a hidden field in the POST data - we check both String doCancel = request.getParameter("sakai.cancel"); String doUpdate = request.getParameter("sakai.update"); // Our next challenge is to pick which action the previous view // has told us to do. Note that the view may place several actions // on the screen and the user may have an option to pick between // them. Make sure we handle the "no action" fall-through. pSession.removeAttribute("error.message"); if ( doCancel != null ) { response.setPortletMode(PortletMode.VIEW); } else if ( doUpdate != null ) { processActionEdit(request, response); } else { log.debug("Unknown action"); response.setPortletMode(PortletMode.VIEW); } log.debug("==== End of ProcessAction ===="); }
Example 10
Source File: IMSBLTIPortlet.java From sakai with Educational Community License v2.0 | 5 votes |
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { log.debug("==== processAction called ===="); String action = request.getParameter("sakai.action"); log.debug("sakai.action = {}", action); PortletSession pSession = request.getPortletSession(true); // Clear before Action clearErrorMessage(request); String view = (String) pSession.getAttribute("sakai.view"); log.debug("sakai.view={}", view); if ( action == null ) { // Do nothing } else if ( action.equals("main") ) { response.setPortletMode(PortletMode.VIEW); } else if ( action.equals("edit") ) { pSession.setAttribute("sakai.view", "edit"); } else if ( action.equals("edit.reset") ) { pSession.setAttribute("sakai.view","edit.reset"); } else if (action.equals("edit.setup")){ pSession.setAttribute("sakai.view","edit.setup"); } else if ( action.equals("edit.clear") ) { clearSession(request); response.setPortletMode(PortletMode.VIEW); pSession.setAttribute("sakai.view", "main"); } else if ( action.equals("edit.do.reset") ) { processActionReset(action,request, response); } else if ( action.equals("edit.save") ) { processActionSave(action,request, response); } log.debug("==== End of ProcessAction ===="); }
Example 11
Source File: SakaiIFrame.java From sakai with Educational Community License v2.0 | 4 votes |
public void processActionEdit(ActionRequest request, ActionResponse response) throws PortletException, IOException { // TODO: Check Role // Stay in EDIT mode unless we are successful response.setPortletMode(PortletMode.EDIT); String id = request.getParameter(LTIService.LTI_ID); String toolId = request.getParameter(LTIService.LTI_TOOL_ID); Properties reqProps = new Properties(); Enumeration<String> names = request.getParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); reqProps.setProperty(name, request.getParameter(name)); } Placement placement = ToolManager.getCurrentPlacement(); m_ltiService.updateContent(Long.parseLong(id), reqProps, placement.getContext()); String fa_icon = (String) request.getParameter(LTIService.LTI_FA_ICON); if ( fa_icon != null && fa_icon.length() > 0 ) { placement.getPlacementConfig().setProperty("imsti.fa_icon",fa_icon); } // get the site toolConfiguration, if this is part of a site. ToolConfiguration toolConfig = SiteService.findTool(placement.getId()); String title = reqProps.getProperty("title"); if (StringUtils.isNotBlank(title)) { // Set the title for the page toolConfig.getContainingPage().setTitle(title); try { SiteService.save(SiteService.getSite(toolConfig.getSiteId())); } catch (Exception e) { log.error("Failed to save site", e); } } placement.save(); response.setPortletMode(PortletMode.VIEW); }
Example 12
Source File: SakaiIFrame.java From sakai with Educational Community License v2.0 | 4 votes |
public void processActionEdit(ActionRequest request, ActionResponse response) throws PortletException, IOException { // TODO: Check Role // Stay in EDIT mode unless we are successful response.setPortletMode(PortletMode.EDIT); String id = request.getParameter(LTIService.LTI_ID); String toolId = request.getParameter(LTIService.LTI_TOOL_ID); Properties reqProps = new Properties(); Enumeration<String> names = request.getParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); reqProps.setProperty(name, request.getParameter(name)); } Placement placement = ToolManager.getCurrentPlacement(); m_ltiService.updateContent(Long.parseLong(id), reqProps, placement.getContext()); String fa_icon = (String) request.getParameter(LTIService.LTI_FA_ICON); if ( fa_icon != null && fa_icon.length() > 0 ) { placement.getPlacementConfig().setProperty("imsti.fa_icon",fa_icon); } // get the site toolConfiguration, if this is part of a site. ToolConfiguration toolConfig = SiteService.findTool(placement.getId()); String title = reqProps.getProperty("title"); if (StringUtils.isNotBlank(title)) { // Set the title for the page toolConfig.getContainingPage().setTitle(title); try { SiteService.save(SiteService.getSite(toolConfig.getSiteId())); } catch (Exception e) { log.error("Failed to save site", e); } } placement.save(); response.setPortletMode(PortletMode.VIEW); }