List of usage examples for org.springframework.web.servlet.support RequestContextUtils getLocale
public static Locale getLocale(HttpServletRequest request)
From source file:net.vksn.ecm.spring.tiles3.TilesView.java
/** * Create a Tiles {@link Request}. This implementation creates a * {@link ServletRequest}./* www.j a va2s . c o m*/ * * @param request the current request * @param response the current response * @return the Tiles request */ protected Request createTilesRequest(final HttpServletRequest request, HttpServletResponse response) { return new ServletRequest(this.applicationContext, request, response) { @Override public Locale getRequestLocale() { return RequestContextUtils.getLocale(request); } }; }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.list.filemetadata.FileMetadataParamDefMultiController.java
@RequestMapping(value = "lists/file-metadata-definitions/list.html", method = RequestMethod.POST) public String onSubmit(@ModelAttribute("selectGroupCommand") SelectGroupCommand selectGroupCommand, ModelMap model, HttpServletRequest request) { String defaultFileMetadataParamDef = messageSource.getMessage("label.defaultFileMetadataParamDef", null, RequestContextUtils.getLocale(request)); fillAuthResearchGroupList(defaultFileMetadataParamDef); if (!researchGroupList.isEmpty()) { fillFileMetadataParamDefList(selectGroupCommand.getResearchGroupId()); }/*w w w. j a va 2s . c o m*/ boolean canEdit = auth.isAdmin() || auth.userIsExperimenter(); model.addAttribute("userIsExperimenter", canEdit); model.addAttribute("researchGroupList", researchGroupList); model.addAttribute("fileMetadataParamDefList", fileMetadataParamDefList); return "lists/fileMetadataParams/list"; }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.list.personoptparamdef.AddPersonOptParamDefController.java
@RequestMapping(value = "lists/person-optional-parameters/add.html", method = RequestMethod.GET) protected String showAddForm(@RequestParam("groupid") String idString, ModelMap model, HttpServletRequest request) throws Exception { AddPersonOptParamDefCommand data = new AddPersonOptParamDefCommand(); if (auth.userIsExperimenter() || auth.isAdmin()) { if (idString != null) { int id = Integer.parseInt(idString); data.setResearchGroupId(id); if (id != DEFAULT_ID) { String title = researchGroupDao.getResearchGroupTitle(id); data.setResearchGroupTitle(title); } else { String defaultPersonOptParamDef = messageSource.getMessage("label.defaultPersonOptParamDef", null, RequestContextUtils.getLocale(request)); data.setResearchGroupTitle(defaultPersonOptParamDef); }// w w w .j a va 2 s .co m } model.addAttribute("userIsExperimenter", auth.userIsExperimenter()); model.addAttribute("addPersonOptParamDef", data); return "lists/personAdditionalParams/addItemForm"; } else { return "lists/userNotExperimenter"; } }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.list.experimentoptparamdef.ExperimentOptParamDefMultiController.java
@RequestMapping(value = "lists/experiment-optional-parameters/list.html", method = RequestMethod.POST) public String onSubmit(@ModelAttribute("selectGroupCommand") SelectGroupCommand selectGroupCommand, ModelMap model, HttpServletRequest request) { String defaultExperimentOptParamDef = messageSource.getMessage("label.defaultExperimentOptParamDef", null, RequestContextUtils.getLocale(request)); fillAuthResearchGroupList(defaultExperimentOptParamDef); if (!researchGroupList.isEmpty()) { fillExperimentOptParamDefList(selectGroupCommand.getResearchGroupId()); }//from ww w.ja v a2s . co m boolean canEdit = auth.isAdmin() || auth.userIsExperimenter(); model.addAttribute("userIsExperimenter", canEdit); model.addAttribute("researchGroupList", researchGroupList); model.addAttribute("experimentOptParamDefList", experimentOptParamDefList); return "lists/measurationAdditionalParams/list"; }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.list.filemetadata.AddFileMetadataParamDefController.java
@RequestMapping(value = "lists/file-metadata-definitions/add.html", method = RequestMethod.GET) protected String showAddForm(@RequestParam("groupid") String idString, ModelMap model, HttpServletRequest request) throws Exception { AddFileMetadataParamDefCommand data = new AddFileMetadataParamDefCommand(); if (auth.userIsExperimenter() || auth.isAdmin()) { if (idString != null) { int id = Integer.parseInt(idString); data.setResearchGroupId(id); if (id != DEFAULT_ID) { String title = researchGroupDao.getResearchGroupTitle(id); data.setResearchGroupTitle(title); } else { String defaultFileMetadataParamDef = messageSource.getMessage( "label.defaultFileMetadataParamDef", null, RequestContextUtils.getLocale(request)); data.setResearchGroupTitle(defaultFileMetadataParamDef); }//from w ww .j ava2 s . c o m } model.addAttribute("userIsExperimenter", auth.userIsExperimenter()); model.addAttribute("addFileMetadataParamDef", data); return "lists/fileMetadataParams/addItemForm"; } else { return "lists/userNotExperimenter"; } }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.list.experimentoptparamdef.AddExperimentOptParamDefController.java
@RequestMapping(value = "lists/experiment-optional-parameters/add.html", method = RequestMethod.GET) protected String showAddForm(@RequestParam("groupid") String idString, ModelMap model, HttpServletRequest request) throws Exception { AddExperimentOptParamDefCommand data = new AddExperimentOptParamDefCommand(); if (auth.userIsExperimenter() || auth.isAdmin()) { if (idString != null) { int id = Integer.parseInt(idString); data.setResearchGroupId(id); if (id != DEFAULT_ID) { String title = researchGroupDao.getResearchGroupTitle(id); data.setResearchGroupTitle(title); } else { String defaultExperimentOptParamDef = messageSource.getMessage( "label.defaultExperimentOptParamDef", null, RequestContextUtils.getLocale(request)); data.setResearchGroupTitle(defaultExperimentOptParamDef); }//from ww w. j a va 2s . c om } model.addAttribute("userIsExperimenter", auth.userIsExperimenter()); model.addAttribute("addExperimentOptParamDef", data); return "lists/measurationAdditionalParams/addItemForm"; } else { return "lists/userNotExperimenter"; } }
From source file:com.krawler.spring.organizationChart.organizationChartController.java
public ModelAndView insertNode(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); String retMsg = ""; //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try {// ww w .j av a 2 s.c om String parentid = StringUtil.checkForNull(request.getParameter("fromId")); String childid = StringUtil.checkForNull(request.getParameter("userid")); HashMap<String, Object> hm = organizationService.insertNode(parentid, childid); boolean success = Boolean.parseBoolean(hm.get("success").toString()); User parent = (User) hm.get("parent"); User child = (User) hm.get("child"); if (parent != null && child != null) { auditTrailDAOObj.insertAuditLog(AuditAction.ORGANIZATION_CHART_NODE_ASSIGNED, child.getFirstName() + " " + child.getLastName() + " re-assigned to " + parent.getFirstName() + " " + parent.getLastName(), request, "0"); } if (success) { retMsg = "{success:true}"; } else { retMsg = "{success:false,msg:\"" + messageSource.getMessage("hrms.common.not.assign.parent.node.employee.role", null, "Could not assign because, parent node has Employee role.", RequestContextUtils.getLocale(request)) + "\"}"; } jobj.put("data", retMsg); jobj1.put("valid", true); jobj1.put("data", jobj); jobj1.put("success", true); txnManager.commit(status); } catch (Exception e) { logger.warn("General exception in insertNode()", e); txnManager.rollback(status); } return new ModelAndView("jsonView", "model", jobj1.toString()); }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.list.weather.WeatherMultiController.java
@ModelAttribute("researchGroupList") private List<ResearchGroup> fillAuthResearchGroupList(HttpServletRequest request) { String defaultName = messageSource.getMessage("label.defaultWeather", null, RequestContextUtils.getLocale(request)); Person loggedUser = personDao.getLoggedPerson(); if (loggedUser.getAuthority().equals("ROLE_ADMIN")) { ResearchGroup defaultGroup = new ResearchGroup(DEFAULT_ID, loggedUser, defaultName, "-"); researchGroupList = researchGroupDao.getAllRecords(); researchGroupList.add(0, defaultGroup); } else {/*from w w w .j a v a2 s .c o m*/ researchGroupList = researchGroupDao.getResearchGroupsWhereMember(loggedUser); } return researchGroupList; }
From source file:com.krawler.spring.organizationChart.organizationChartController.java
public ModelAndView getMappedUsers(HttpServletRequest request, HttpServletResponse response) { JSONObject jobj = new JSONObject(); JSONObject jobj1 = new JSONObject(); try {// w w w . j a v a 2 s. c om String userid = sessionHandlerImplObj.getUserid(request); String companyid = sessionHandlerImplObj.getCompanyid(request); Locale locale = RequestContextUtils.getLocale(request); jobj = organizationService.getMappedUsers(userid, companyid, locale); jobj1.put("valid", true); jobj1.put("data", jobj); jobj1.put("success", true); } catch (Exception e) { logger.warn("General exception in getMappedUsers()", e); } return new ModelAndView("jsonView", "model", jobj1.toString()); }
From source file:nl.surfnet.coin.selfservice.service.impl.CsaMock.java
private String getLocale() { Locale locale = null;/* w w w . ja va 2 s . c o m*/ ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (sra != null) { HttpServletRequest request = sra.getRequest(); if (request != null) { locale = RequestContextUtils.getLocale(request); } } return locale != null ? locale.getLanguage() : "en"; }