List of usage examples for javax.servlet.http HttpServletRequest getLocale
public Locale getLocale();
Locale
that the client will accept content in, based on the Accept-Language header. From source file:com.feilong.taglib.display.pager.PagerTag.java
/** * Builds the pager params./*ww w. j a va2s . c o m*/ * * @param request * the request * @return the pager params * @since 1.7.2 */ private PagerParams buildPagerParams(HttpServletRequest request) { // ? String pageUrl = RequestUtil.getRequestFullURL(request, charsetType); // **************************************************************************** PagerParams pagerParams = new PagerParams(count, pageUrl); pagerParams.setCurrentPageNo(PagerHelper.getCurrentPageNo(request, pageParamName)); // ?? pagerParams.setPageSize(pageSize); pagerParams.setPageParamName(pageParamName); pagerParams.setVmPath(vmPath); pagerParams.setCharsetType(charsetType); pagerParams.setLocale(defaultIfNull(toLocale(locale), request.getLocale())); pagerParams.setMaxShowPageNo(maxShowPageNo); pagerParams.setSkin(skin); pagerParams.setMaxIndexPages(maxIndexPages); pagerParams.setDebugIsNotParseVM(getDebugIsNotParseVM(request)); return pagerParams; }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractTasksController.java
@RequestMapping(value = "/approval-task", method = RequestMethod.POST) @ResponseBody/*from ww w .j a v a2 s. co m*/ public String actOnApprovalTask(@RequestParam(value = "uuid", required = true) String pendingActionId, @RequestParam(value = "state", required = true) String state, @RequestParam(value = "memo", required = false) String memo, HttpServletRequest request) { logger.debug("### In actOnPendingAction() method starting..."); Task.State stateChangeTo; if (state.equalsIgnoreCase("success")) { stateChangeTo = Task.State.SUCCESS; } else { if (StringUtils.isEmpty(memo)) { throw new InvalidAjaxRequestException(messageSource.getMessage( "ui.accounts.all.pending.changes.memorequired", null, getCurrentUser().getLocale())); } stateChangeTo = Task.State.FAILURE; } Task currentTask = taskService.get(pendingActionId); Task action = taskService.completeTask(currentTask, stateChangeTo, getCurrentUser(), memo); logger.debug("### In actOnPendingAction() method ending."); return messageSource.getMessage("ui.task.state." + action.getState(), null, request.getLocale()); }
From source file:net.duckling.ddl.web.controller.LynxEditPageController.java
@RequestMapping(params = "func=restoreDraft") public ModelAndView restoreDraft(HttpServletRequest request, @RequestParam("rid") Integer rid) { int bid = getPatentRidFromRequest(request); VWBContext context = getEditPageContext(request, rid); PageRender render = getPageRender(rid, context); String htmlText = request.getParameter("draftText"); ModelAndView mv = loadEditorWithContent(context, render, htmlText, request.getLocale().toString()); mv.addObject("bid", bid); return mv;//from w w w.j a v a2s. c om }
From source file:net.duckling.ddl.web.controller.LynxEditPageController.java
@RequestMapping(params = "func=unrestoreDraft") public ModelAndView unrestoreDraft(HttpServletRequest request, @RequestParam("rid") Integer rid) { VWBContext context = getEditPageContext(request, rid); int bid = getPatentRidFromRequest(request); String htmlText = request.getParameter("publishText"); PageRender render = getPageRender(rid, context); ModelAndView mv = loadEditorWithContent(context, render, htmlText, request.getLocale().toString()); mv.addObject("bid", bid); return mv;/*w ww . j a v a 2 s.com*/ }
From source file:fr.paris.lutece.plugins.document.service.DocumentContentService.java
/** * Gets the category list portlet linked with the document * * @param request The Http request//from w w w .j a v a 2 s.co m * @param document The document * @param nPortletId The ID of the documents list portlet where the document * has been published. * @param nMode The current mode. * @return The HTML code of the categories list portlet as a String */ private String getRelatedDocumentsPortlet(HttpServletRequest request, Document document, int nPortletId, int nMode) { if ((nMode != MODE_ADMIN) && (document.getCategories() != null) && (document.getCategories().size() > 0)) { HashMap<String, Object> model = new HashMap<String, Object>(); List<Document> listRelatedDocument = DocumentHome.findByRelatedCategories(document, request.getLocale()); List<Document> listDocument = new ArrayList<Document>(); ReferenceList listDocumentPortlet = new ReferenceList(); // Create list of related documents from the specified categories of input document for (Document relatedDocument : listRelatedDocument) { // Get list of portlets for each document for (Portlet portlet : PublishingService.getInstance() .getPortletsByDocumentId(Integer.toString(relatedDocument.getId()))) { // Check if document and portlet are published and document is not the input document if ((PublishingService.getInstance().isPublished(relatedDocument.getId(), portlet.getId())) && (portlet.getStatus() == Portlet.STATUS_PUBLISHED) && (relatedDocument.isValid()) && (relatedDocument.getId() != document.getId())) { listDocumentPortlet.addItem(Integer.toString(relatedDocument.getId()), Integer.toString(portlet.getId())); listDocument.add(relatedDocument); break; } } } model.put(MARK_DOCUMENT_CATEGORIES_LIST, listDocument); model.put(MARK_PORTLET_ID_LIST, listDocumentPortlet); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_DOCUMENT_CATEGORIES, request.getLocale(), model); return template.getHtml(); } else { return StringUtils.EMPTY; } }
From source file:fr.paris.lutece.plugins.workflow.modules.ticketing.web.EditTicketXPage.java
/** * Do process the workflow action/*from ww w . j av a 2 s .c o m*/ * @param request HttpServletRequest * @param nIdAction the action id * @param editableTicket editable ticket * @return {@code true} if the action is processed, {@code false} otherwise */ private boolean doProcessWorkflowAction(HttpServletRequest request, int nIdAction, EditableTicket editableTicket) { boolean bIsActionProccessed = false; String strAction = request.getParameter(PARAMETER_ACTION); if (StringUtils.isNotBlank(strAction)) { if (ACTION_DO_MODIFY_TICKET.equals(strAction)) { TicketHelper.registerDefaultAdminUser(request); Ticket ticket = WorkflowTicketingUtils.findTicketByIdHistory(editableTicket.getIdHistory()); TicketCategory ticketCategory = TicketCategoryHome.findByPrimaryKey(ticket.getIdTicketCategory()); _workflowService.doProcessAction(ticket.getId(), Ticket.TICKET_RESOURCE_TYPE, nIdAction, ticketCategory.getId(), request, request.getLocale(), false); bIsActionProccessed = true; } } return bIsActionProccessed; }
From source file:fragment.web.AbstractConnectorControllerTest.java
@Test public void testUploadServiceInstanceLogoInvalidFile() throws Exception { Configuration configuration = configurationService .locateConfigurationByName(Names.com_citrix_cpbm_portal_settings_images_uploadPath); configuration.setValue("src\\test\\resources"); configurationService.update(configuration); ServiceInstance serviceInstance = serviceInstanceDao.find(1L); Assert.assertEquals(null, serviceInstance.getImagePath()); MultipartFile logo = new MockMultipartFile("ServiceInstanceLogo.jpeg", "ServiceInstanceLogo.jpe", "byte", "ServiceInstance".getBytes()); ServiceInstanceLogoForm form = new ServiceInstanceLogoForm(serviceInstance); form.setLogo(logo);//from w w w. ja v a 2 s . co m BindingResult result = validate(form); HttpServletRequest request = new MockHttpServletRequest(); map = new ModelMap(); String resultString = controller.uploadServiceInstanceLogo(form, result, request, map); Assert.assertNotNull(resultString); String Error = messageSource.getMessage(result.getFieldError("logo").getCode(), null, request.getLocale()); Assert.assertEquals(Error, resultString); serviceInstance = serviceInstanceDao.find(1L); Assert.assertEquals(null, serviceInstance.getImagePath()); }
From source file:fragment.web.AbstractConnectorControllerTest.java
@Test public void testUploadServiceInstanceLogoNullDirectoryPath() throws Exception { Configuration configuration = configurationService .locateConfigurationByName(Names.com_citrix_cpbm_portal_settings_images_uploadPath); configuration.setValue(null);/* w w w . j av a 2s. co m*/ configurationService.update(configuration); ServiceInstance serviceInstance = serviceInstanceDao.find(1L); Assert.assertEquals(null, serviceInstance.getImagePath()); MultipartFile logo = new MockMultipartFile("ServiceInstanceLogo.jpeg", "ServiceInstanceLogo.jpeg", "byte", "ServiceInstance".getBytes()); ServiceInstanceLogoForm form = new ServiceInstanceLogoForm(serviceInstance); form.setLogo(logo); BindingResult result = validate(form); HttpServletRequest request = new MockHttpServletRequest(); map = new ModelMap(); String resultString = controller.uploadServiceInstanceLogo(form, result, request, map); Assert.assertNotNull(resultString); String Error = messageSource.getMessage(result.getFieldError("logo").getCode(), null, request.getLocale()); Assert.assertEquals(Error, resultString); serviceInstance = serviceInstanceDao.find(1L); Assert.assertEquals(null, serviceInstance.getImagePath()); }
From source file:fr.paris.lutece.plugins.extend.modules.feedback.web.component.FeedbackResourceExtenderComponent.java
/** * {@inheritDoc}//w w w. ja v a 2 s . co m */ @Override public String getConfigHtml(ResourceExtenderDTO resourceExtender, Locale locale, HttpServletRequest request) { ReferenceList listIdsMailingList = new ReferenceList(); listIdsMailingList.addItem(-1, I18nService .getLocalizedString(FeedbackConstants.PROPERTY_FEEDBACK_CONFIG_LABEL_NO_MAILING_LIST, locale)); listIdsMailingList.addAll(AdminMailingListService.getMailingLists(AdminUserService.getAdminUser(request))); Map<String, Object> model = new HashMap<String, Object>(); model.put(FeedbackConstants.MARK_FEEDBACK_CONFIG, _configService.find(resourceExtender.getIdExtender())); model.put(FeedbackConstants.MARK_LIST_IDS_MAILING_LIST, listIdsMailingList); model.put(FeedbackConstants.MARK_WEBAPP_URL, AppPathService.getBaseUrl(request)); model.put(FeedbackConstants.MARK_LOCALE, locale); HtmlTemplate template = AppTemplateService.getTemplate(TEMPLATE_FEEDBACK_CONFIG, request.getLocale(), model); return template.getHtml(); }