List of usage examples for org.springframework.web.context.request WebRequest setAttribute
void setAttribute(String name, Object value, int scope);
From source file:org.openmrs.web.controller.concept.ConceptAttributeTypeFormController.java
private String purgeConceptAttributeType(WebRequest request, ConceptAttributeType conceptAttributeType, ConceptService conceptService) { try {//from w w w . j a va 2 s . co m conceptService.purgeConceptAttributeType(conceptAttributeType); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "ConceptAttributeType.purgedSuccessfully", WebRequest.SCOPE_SESSION); } catch (Exception e) { request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.object.inuse.cannot.purge", WebRequest.SCOPE_SESSION); } return CONCEPT_ATTRIBUTE_TYPES_LIST_URL; }
From source file:com.seajas.search.codex.social.interceptor.AbstractConnectInterceptor.java
/** * Add the username-state parameter so that we can track this connection by its username. * /*from www . j a v a 2s . co m*/ * @param parameters * @param request */ protected void addState(final MultiValueMap<String, String> parameters, final WebRequest request) { String username = request.getParameter("username"); if (logger.isInfoEnabled()) logger.info("Setting state username in session to '" + username + "' for access token request"); request.setAttribute(REQUEST_STATE_USERNAME, username, RequestAttributes.SCOPE_SESSION); }
From source file:org.openmrs.web.controller.encounter.LocationTagController.java
/** * Retire a locationTag/*w ww . j a va 2 s . c o m*/ */ @RequestMapping(method = RequestMethod.POST, value = "/admin/locations/locationTagRetire") public String retire(WebRequest request, @RequestParam("id") LocationTag locationTag, @RequestParam("retireReason") String retireReason) { Context.getLocationService().retireLocationTag(locationTag, retireReason); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("LocationTag.retired"), WebRequest.SCOPE_SESSION); return "redirect:/admin/locations/locationTag.list"; }
From source file:org.focusns.web.oauth.OAuthController.java
@RequestMapping("/callback") public String callback(@RequestParam String code, WebRequest webRequest) { OAuthService oAuthService = (OAuthService) webRequest.getAttribute("oAuthService", WebRequest.SCOPE_SESSION);//from w ww. ja v a 2 s . co m // Verifier verifier = new Verifier(code); Token accessToken = oAuthService.getAccessToken(EMPTY_TOKEN, verifier); webRequest.setAttribute("accessToken", accessToken, WebRequest.SCOPE_SESSION); // return "redirect:/register"; }
From source file:com.nixmash.springdata.mvc.controller.UserController.java
@RequestMapping(value = "/signup", method = RequestMethod.GET) public String signupForm(@ModelAttribute SocialUserDTO socialUserDTO, WebRequest request, Model model) { if (request.getUserPrincipal() != null) return "redirect:/"; else {/*from w w w.j a v a2s . c om*/ Connection<?> connection = providerSignInUtils.getConnectionFromSession(request); request.setAttribute("connectionSubheader", webUI.parameterizedMessage(MESSAGE_KEY_SOCIAL_SIGNUP, StringUtils.capitalize(connection.getKey().getProviderId())), RequestAttributes.SCOPE_REQUEST); socialUserDTO = createSocialUserDTO(request, connection); ConnectionData connectionData = connection.createData(); SignInUtils.setUserConnection(request, connectionData); model.addAttribute(MODEL_ATTRIBUTE_SOCIALUSER, socialUserDTO); return SIGNUP_VIEW; } }
From source file:org.openmrs.web.controller.location.LocationAttributeTypeFormController.java
/** * Handle submission for create or edit//from www.j a v a 2 s. c o m */ @RequestMapping(value = "/admin/locations/locationAttributeType", method = RequestMethod.POST) public String handleSubmit(WebRequest request, @ModelAttribute("attributeType") LocationAttributeType attributeType, BindingResult errors) { LocationService service = Context.getLocationService(); if (request.getParameter("purge") != null) { try { service.purgeLocationAttributeType(attributeType); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "LocationAttributeType.purgedSuccessfully", WebRequest.SCOPE_SESSION); } catch (Exception e) { request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.object.inuse.cannot.purge", WebRequest.SCOPE_SESSION); } return "redirect:locationAttributeTypes.list"; } new LocationAttributeTypeValidator().validate(attributeType, errors); if (errors.hasErrors()) { return null; // redisplay the form } else { if (request.getParameter("save") != null) { Context.getLocationService().saveLocationAttributeType(attributeType); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("LocationAttributeType.saved"), WebRequest.SCOPE_SESSION); } else if (request.getParameter("retire") != null) { String retireReason = request.getParameter("retireReason"); if (attributeType.getId() != null && !(StringUtils.hasText(retireReason))) { errors.reject("retireReason", "general.retiredReason.empty"); return null; } Context.getLocationService().retireLocationAttributeType(attributeType, retireReason); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("LocationAttributeType.retired"), WebRequest.SCOPE_SESSION); } else if (request.getParameter("unretire") != null) { Context.getLocationService().unretireLocationAttributeType(attributeType); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("LocationAttributeType.unretired"), WebRequest.SCOPE_SESSION); } return "redirect:/admin/locations/locationAttributeTypes.list"; } }
From source file:org.openmrs.module.dhisreport.web.controller.ReportDefinitionController.java
@RequestMapping(value = "/module/dhisreport/deleteReportDefinition", method = RequestMethod.GET) public String deleteReportDefinition(ModelMap model, @RequestParam(value = "reportDefinition_id", required = false) Integer reportDefinition_id, WebRequest webRequest) { DHIS2ReportingService service = Context.getService(DHIS2ReportingService.class); model.addAttribute("user", Context.getAuthenticatedUser()); ReportDefinition rd = service.getReportDefinition(reportDefinition_id); service.purgeReportDefinition(rd);/*from w ww . j ava2s .c o m*/ webRequest.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("dhisreport.deleteSuccess"), WebRequest.SCOPE_SESSION); return "redirect:/module/dhisreport/listDhis2Reports.form"; }
From source file:org.halkneistiyor.social.web.SignupController.java
@RequestMapping(value = "/signup", method = RequestMethod.GET) public SignupForm signupForm(WebRequest request) { Connection<?> connection = ProviderSignInUtils.getConnection(request); if (connection != null) { String txt = "Your " + StringUtils.capitalize(connection.getKey().getProviderId()) + " account is not associated with an account. If you're new, please sign up."; Message message = new Message(MessageType.INFO, txt); request.setAttribute("message", message, WebRequest.SCOPE_REQUEST); return SignupForm.fromProviderUser(connection.fetchUserProfile()); } else {//from w w w.java 2 s . c o m return new SignupForm(); } }
From source file:org.openmrs.module.dhisreport.web.controller.LocationMappingController.java
@RequestMapping(value = "/module/dhisreport/mapLocations", method = RequestMethod.POST) public String mapLocations(ModelMap model, @RequestParam(value = "DHIS2OrgUnits", required = true) String dhis2OrgUnitCode, @RequestParam(value = "openmrsLocations", required = true) String openmrsLocationName, WebRequest webRequest) { System.out.println("org unit does not exits and it is : " + dhis2OrgUnitCode); String referer = webRequest.getHeader("Referer"); if (dhis2OrgUnitCode.equals("")) { System.out.println("org unit does not exits"); webRequest.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("dhisreport.orgUnitCodeDoesNotExist"), WebRequest.SCOPE_SESSION); return "redirect:" + referer; }/*from w w w .j a v a 2 s.c o m*/ List<Location> locationList = new ArrayList<Location>(); locationList.addAll(Context.getLocationService().getAllLocations()); Location loc = Context.getLocationService().getLocation(openmrsLocationName); if (loc == null) { webRequest.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("dhisreport.openMRSLocationDoesNotExist"), WebRequest.SCOPE_SESSION); return "redirect:" + referer; } List<LocationAttributeType> attributeTypes = Context.getLocationService().getAllLocationAttributeTypes(); for (LocationAttributeType lat : attributeTypes) { if (lat.getName().equals("CODE")) { LocationAttribute locationAttribute = new LocationAttribute(); locationAttribute.setAttributeType(lat); locationAttribute.setValue(dhis2OrgUnitCode); loc.setAttribute(locationAttribute); Context.getLocationService().saveLocation(loc); webRequest.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("dhisreport.openMRSLocationMapped"), WebRequest.SCOPE_SESSION); return "redirect:" + referer; } } LocationAttributeType attributetype = new LocationAttributeType(); attributetype.setName("CODE"); attributetype.setDescription("Corresponding Value of ORG UNITS for DHIS"); attributetype.setMinOccurs(0); attributetype.setMaxOccurs(1); attributetype.setDatatypeClassname("org.openmrs.customdatatype.datatype.FreeTextDatatype"); Context.getLocationService().saveLocationAttributeType(attributetype); LocationAttribute locationAttribute = new LocationAttribute(); locationAttribute.setAttributeType(attributetype); locationAttribute.setValue(dhis2OrgUnitCode); loc.setAttribute(locationAttribute); Context.getLocationService().saveLocation(loc); webRequest.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("dhisreport.openMRSLocationMapped"), WebRequest.SCOPE_SESSION); return "redirect:" + referer; }
From source file:org.openmrs.web.controller.encounter.LocationTagController.java
/** * Handle submission for editing a LocationTag (for editing its name/description) *///from ww w .j a v a 2s.c o m @RequestMapping(method = RequestMethod.POST, value = "/admin/locations/locationTagEdit") public String handleEditSubmission(WebRequest request, @ModelAttribute("locationTag") LocationTag locationTag, BindingResult result, SessionStatus status) { new LocationTagValidator().validate(locationTag, result); if (result.hasErrors()) { return "/admin/locations/locationTagEdit"; } else { Context.getLocationService().saveLocationTag(locationTag); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage("LocationTag.saved"), WebRequest.SCOPE_SESSION); status.setComplete(); return "redirect:/admin/locations/locationTag.list"; } }