org.springframework.web.servlet.mvc.support.RedirectAttributes Java Examples

The following examples show how to use org.springframework.web.servlet.mvc.support.RedirectAttributes. 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: EventsController.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@PostMapping(value = "/new")
public String createEvent(@Valid CreateEventForm createEventForm, BindingResult result,
        RedirectAttributes redirectAttributes) {
    if (result.hasErrors()) {
        return "events/create";
    }
    CalendarUser attendee = calendarService.findUserByEmail(createEventForm.getAttendeeEmail());
    if (attendee == null) {
        result.rejectValue("attendeeEmail", "attendeeEmail.missing",
                "Could not find a user for the provided Attendee Email");
    }
    if (result.hasErrors()) {
        return "events/create";
    }
    Event event = new Event();
    event.setAttendee(attendee);
    event.setDescription(createEventForm.getDescription());
    event.setOwner(userContext.getCurrentUser());
    event.setSummary(createEventForm.getSummary());
    event.setWhen(createEventForm.getWhen());
    calendarService.createEvent(event);
    redirectAttributes.addFlashAttribute("message", "Successfully added the new event");
    return "redirect:/events/my";
}
 
Example #2
Source File: StudentBatchEditController.java    From zhcet-web with Apache License 2.0 6 votes vote down vote up
@PostMapping("/status") // We use 'student' instead of 'students' so that it does not clash with 'studentPost' method above
public String studentStatus(RedirectAttributes redirectAttributes, @RequestParam List<String> enrolments, @RequestParam String status) {
    if (Strings.isNullOrEmpty(status)) {
        redirectAttributes.addFlashAttribute("section_error", "Status was unchanged");
        return "redirect:/admin/dean/students";
    }

    try {
        studentEditService.changeStatuses(enrolments, status);
        redirectAttributes.addFlashAttribute("section_success", "Statuses changed successfully");
    } catch (Exception e) {
        log.error("Error changing statuses", e);
        redirectAttributes.addFlashAttribute("section_error", "Unknown error while changing statuses");
    }

    return "redirect:/admin/dean/students";
}
 
Example #3
Source File: StoreInfoController.java    From lemon with Apache License 2.0 6 votes vote down vote up
@RequestMapping("store-info-save")
public String save(@ModelAttribute StoreInfo storeInfo,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    Long id = storeInfo.getId();
    StoreInfo dest = null;

    if (id != null) {
        dest = storeInfoManager.get(id);
        beanMapper.copy(storeInfo, dest);
    } else {
        dest = storeInfo;
        dest.setTenantId(tenantId);
    }

    storeInfoManager.save(dest);
    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/store/store-info-list.do";
}
 
Example #4
Source File: FilterConfigController.java    From kafka-webview with MIT License 6 votes vote down vote up
/**
 * GET Displays edit filter form.
 */
@RequestMapping(path = "/edit/{id}", method = RequestMethod.GET)
public String editFilter(
    @PathVariable final Long id,
    final FilterForm filterForm,
    final Model model,
    final RedirectAttributes redirectAttributes) {
    // Retrieve it
    final Optional<Filter> filterOptional = filterRepository.findById(id);
    if (!filterOptional.isPresent()) {
        // Set flash message & redirect
        redirectAttributes.addFlashAttribute("FlashMessage", FlashMessage.newWarning("Unable to find filter!"));
        return "redirect:/configuration/filter";
    }
    final Filter filter = filterOptional.get();

    // Setup breadcrumbs
    setupBreadCrumbs(model, "Edit " + filter.getName(), null);

    // Setup form
    filterForm.setId(filter.getId());
    filterForm.setName(filter.getName());
    filterForm.setClasspath(filter.getClasspath());

    return "configuration/filter/create";
}
 
Example #5
Source File: PostDescribeController.java    From wallride with Apache License 2.0 6 votes vote down vote up
@RequestMapping
public String describe(
		@PathVariable String language,
		@RequestParam long id,
		RedirectAttributes redirectAttributes) {
	Post post = postService.getPostById(id, language);
	if (post == null) {
		throw new HttpNotFoundException();
	}

	redirectAttributes.addAttribute("id", post.getId());
	if (post instanceof Article) {
		return "redirect:/_admin/{language}/articles/describe?id={id}";
	}
	if (post instanceof Page) {
		return "redirect:/_admin/{language}/pages/describe?id={id}";
	}
	throw new HttpNotFoundException();
}
 
Example #6
Source File: AdminProductController.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
/**
 * 保存商品
 */
@RequiresPermissions("shop:product:edit")
@RequestMapping(value = "save")
public String save(@ModelAttribute("product") ShopProduct product, Model model, RedirectAttributes redirectAttributes) {
	if (!beanValidator(model, product)){
		return form(product);
	}
	productService.save(product);

	// delete and save product attributes
	attrService.deleteByProductId(product.getId());
	for (ShopProductAttribute attr : product.getAttributeList()) {
		attrService.save(attr);
	}

	String categoryId = product.getCategory() != null ? product.getCategory().getId() : null;
	addMessage(redirectAttributes, "保存'" + product.getName() + "'成功");
	return "redirect:" + adminPath + "/shop/product/list?repage&category.id=" + categoryId;
}
 
Example #7
Source File: CardInfoController.java    From lemon with Apache License 2.0 6 votes vote down vote up
@RequestMapping("card-info-save")
public String save(@ModelAttribute CardInfo cardInfo,
        @RequestParam Map<String, Object> parameterMap,
        RedirectAttributes redirectAttributes) {
    String tenantId = tenantHolder.getTenantId();
    CardInfo dest = null;

    Long id = cardInfo.getId();

    if (id != null) {
        dest = cardInfoManager.get(id);
        beanMapper.copy(cardInfo, dest);
    } else {
        dest = cardInfo;
        dest.setTenantId(tenantId);
    }

    cardInfoManager.save(dest);

    messageHelper.addFlashMessage(redirectAttributes, "core.success.save",
            "保存成功");

    return "redirect:/card/card-info-list.do";
}
 
Example #8
Source File: EventsController.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@PostMapping(value = "/new")
public String createEvent(@Valid CreateEventForm createEventForm, BindingResult result,
        RedirectAttributes redirectAttributes) {
    if (result.hasErrors()) {
        return "events/create";
    }
    CalendarUser attendee = calendarService.findUserByEmail(createEventForm.getAttendeeEmail());
    if (attendee == null) {
        result.rejectValue("attendeeEmail", "attendeeEmail.missing",
                "Could not find a user for the provided Attendee Email");
    }
    if (result.hasErrors()) {
        return "events/create";
    }
    Event event = new Event();
    event.setAttendee(attendee);
    event.setDescription(createEventForm.getDescription());
    event.setOwner(userContext.getCurrentUser());
    event.setSummary(createEventForm.getSummary());
    event.setWhen(createEventForm.getWhen());
    calendarService.createEvent(event);
    redirectAttributes.addFlashAttribute("message", "Successfully added the new event");
    return "redirect:/events/my";
}
 
Example #9
Source File: ConfigurationController.java    From zhcet-web with Apache License 2.0 6 votes vote down vote up
@PostMapping
public String configurationPost(RedirectAttributes redirectAttributes, @Valid Config config, BindingResult result) {

    if (result.hasErrors()) {
        redirectAttributes.addFlashAttribute("config", config);
        redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.config", result);
    } else {
        List<String> errors = new ArrayList<>();
        if (config.getTerm() != 'A' && config.getTerm() != 'W')
            errors.add("Term can only be Autumn or Winter");

        if (!errors.isEmpty()) {
            redirectAttributes.addFlashAttribute("config", config);
            redirectAttributes.addFlashAttribute("errors", errors);
        } else {
            configurationService.save(toConfigModel(config));
            redirectAttributes.addFlashAttribute("success", Collections.singletonList("Configuration successfully saved!"));
        }
    }

    return "redirect:/admin/dean/configuration";
}
 
Example #10
Source File: GroupController.java    From es with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "{group}/batch/delete", method = RequestMethod.GET)
public String batchDeleteGroupRelation(
        @PathVariable("group") Group group,
        @RequestParam("ids") Long[] ids,
        @RequestParam(value = Constants.BACK_URL, required = false) String backURL,
        RedirectAttributes redirectAttributes) {

    this.permissionList.assertHasDeletePermission();

    if (group.getType() == GroupType.user) {
        groupRelationService.delete(ids);
    }

    if (group.getType() == GroupType.organization) {
        groupRelationService.delete(ids);
    }

    redirectAttributes.addFlashAttribute(Constants.MESSAGE, "删除成功");
    return redirectToUrl(backURL);

}
 
Example #11
Source File: CreateEditMatchController.java    From fredbet with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
@PreAuthorize("hasAuthority('" + FredBetPermission.PERM_EDIT_MATCH + "')")
@PostMapping
public String save(@Valid CreateEditMatchCommand createEditMatchCommand, BindingResult result, RedirectAttributes redirect, Model model) {
    if (result.hasErrors()) {
        model.addAttribute("createEditMatchCommand", createEditMatchCommand);
        addCountriesAndGroups(model);
        return VIEW_EDIT_MATCH;
    }

    save(createEditMatchCommand);

    final String msgKey = createEditMatchCommand.getMatchId() == null ? "msg.match.created" : "msg.match.updated";

    String teamNameOne = webMessageUtil.getTeamName(createEditMatchCommand.getCountryTeamOne(), createEditMatchCommand.getTeamNameOne());
    String teamNameTwo = webMessageUtil.getTeamName(createEditMatchCommand.getCountryTeamTwo(), createEditMatchCommand.getTeamNameTwo());
    webMessageUtil.addInfoMsg(redirect, msgKey, teamNameOne, teamNameTwo);

    return "redirect:/matches#" + createEditMatchCommand.getMatchId();
}
 
Example #12
Source File: IdentityController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 保存Group
 *
 * @return
 */
@RequestMapping(value = "group/save", method = RequestMethod.POST)
public String saveGroup(@RequestParam("groupId") String groupId,
                        @RequestParam("groupName") String groupName,
                        @RequestParam("type") String type,
                        RedirectAttributes redirectAttributes) {
    Group group = identityService.createGroupQuery().groupId(groupId).singleResult();
    if (group == null) {
        group = identityService.newGroup(groupId);
    }
    group.setName(groupName);
    group.setType(type);
    identityService.saveGroup(group);
    redirectAttributes.addFlashAttribute("message", "成功添加组[" + groupName + "]");
    return "redirect:/chapter14/identity/group/list";
}
 
Example #13
Source File: ClusterController.java    From kafka-webview with MIT License 6 votes vote down vote up
/**
 * GET Displays info about a specific broker in a cluster.
 */
@RequestMapping(path = "/{clusterId}/broker/{brokerId}", method = RequestMethod.GET)
public String readBroker(
    @PathVariable final Long clusterId,
    @PathVariable final Integer brokerId,
    final Model model,
    final RedirectAttributes redirectAttributes) {

    // Retrieve by id
    final Cluster cluster = retrieveCluster(clusterId, redirectAttributes);
    if (cluster == null) {
        // redirect
        return "redirect:/";
    }
    model.addAttribute("cluster", cluster);
    model.addAttribute("brokerId", brokerId);

    // Setup breadcrumbs
    setupBreadCrumbs(model)
        .addCrumb(cluster.getName(), "/cluster/" + clusterId)
        .addCrumb("Broker " + brokerId, null);

    // Display template
    return "cluster/readBroker";
}
 
Example #14
Source File: RequestMappingHandlerAdapter.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Nullable
private ModelAndView getModelAndView(ModelAndViewContainer mavContainer,
		ModelFactory modelFactory, NativeWebRequest webRequest) throws Exception {

	modelFactory.updateModel(webRequest, mavContainer);
	if (mavContainer.isRequestHandled()) {
		return null;
	}
	ModelMap model = mavContainer.getModel();
	ModelAndView mav = new ModelAndView(mavContainer.getViewName(), model, mavContainer.getStatus());
	if (!mavContainer.isViewReference()) {
		mav.setView((View) mavContainer.getView());
	}
	if (model instanceof RedirectAttributes) {
		Map<String, ?> flashAttributes = ((RedirectAttributes) model).getFlashAttributes();
		HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
		if (request != null) {
			RequestContextUtils.getOutputFlashMap(request).putAll(flashAttributes);
		}
	}
	return mav;
}
 
Example #15
Source File: RoleController.java    From Shop-for-JavaWeb with MIT License 6 votes vote down vote up
@RequiresPermissions("sys:role:edit")
@RequestMapping(value = "save")
public String save(Role role, Model model, RedirectAttributes redirectAttributes) {
	if(!UserUtils.getUser().isAdmin()&&role.getSysData().equals(Global.YES)){
		addMessage(redirectAttributes, "越权操作,只有超级管理员才能修改此数据!");
		return "redirect:" + adminPath + "/sys/role/?repage";
	}
	if(Global.isDemoMode()){
		addMessage(redirectAttributes, "演示模式,不允许操作!");
		return "redirect:" + adminPath + "/sys/role/?repage";
	}
	if (!beanValidator(model, role)){
		return form(role, model);
	}
	if (!"true".equals(checkName(role.getOldName(), role.getName()))){
		addMessage(model, "保存角色'" + role.getName() + "'失败, 角色名已存在");
		return form(role, model);
	}
	if (!"true".equals(checkEnname(role.getOldEnname(), role.getEnname()))){
		addMessage(model, "保存角色'" + role.getName() + "'失败, 英文名已存在");
		return form(role, model);
	}
	systemService.saveRole(role);
	addMessage(redirectAttributes, "保存角色'" + role.getName() + "'成功");
	return "redirect:" + adminPath + "/sys/role/?repage";
}
 
Example #16
Source File: ModelController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 根据Model部署流程
 */
@RequestMapping(value = "deploy/{modelId}")
public String deploy(@PathVariable("modelId") String modelId, RedirectAttributes redirectAttributes) {
    try {
        Model modelData = repositoryService.getModel(modelId);
        ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
        byte[] bpmnBytes = null;

        BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
        bpmnBytes = new BpmnXMLConverter().convertToXML(model);

        String processName = modelData.getName() + ".bpmn20.xml";
        Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
        redirectAttributes.addFlashAttribute("message", "部署成功,部署ID=" + deployment.getId());
    } catch (Exception e) {
        logger.error("根据模型部署流程失败:modelId={}", modelId, e);
    }
    return "redirect:/chapter20/model/list";
}
 
Example #17
Source File: EmpController.java    From maven-framework-project with MIT License 6 votes vote down vote up
@RequestMapping(value="/create", method=RequestMethod.POST)
public ModelAndView createNewEmp(@ModelAttribute @Valid Emp emp,
		BindingResult result,
		final RedirectAttributes redirectAttributes) {
	
	if (result.hasErrors())
		return new ModelAndView("emp-new");
	
	ModelAndView mav = new ModelAndView();
	String message = "New emp "+emp.getEmpname()+" was successfully created.";
	
	empService.save(emp);
	mav.setViewName("redirect:/index.html");
			
	redirectAttributes.addFlashAttribute("message", message);	
	return mav;		
}
 
Example #18
Source File: DepartmentController.java    From dubai with MIT License 6 votes vote down vote up
@RequestMapping(value = "deactive/{id}")
public String deactive(@PathVariable("id") Long id, RedirectAttributes redirectAttributes) {
    Department dept = departmentService.getDepartment(id);
    if(dept==null) {
        redirectAttributes.addFlashAttribute("error", String.format("不存在id为「%s」的部门", id));
        return redirect("/system/dept");
    }
    try {
        departmentService.deactive(id);
    } catch (ServiceException ex) {
        redirectAttributes.addFlashAttribute("error", ex.getMessage());
        return redirect("/system/dept");
    }
    redirectAttributes.addFlashAttribute("message", "禁用部门『" + dept.getDeptName() + "』成功");
    return redirect("/system/dept");
}
 
Example #19
Source File: BaseTreeableController.java    From es with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "{id}/delete", method = RequestMethod.POST)
public String deleteSelfAndChildren(
        Model model,
        @ModelAttribute("m") M m, BindingResult result,
        RedirectAttributes redirectAttributes) {


    if (permissionList != null) {
        permissionList.assertHasDeletePermission();
    }

    if (m.isRoot()) {
        result.reject("您删除的数据中包含根节点,根节点不能删除");
        return deleteForm(m, model);
    }

    baseService.deleteSelfAndChild(m);
    redirectAttributes.addFlashAttribute(Constants.MESSAGE, "删除成功");
    return redirectToUrl(viewName("success"));
}
 
Example #20
Source File: UserController.java    From es with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "changeStatus/{newStatus}")
public String changeStatus(
        HttpServletRequest request,
        @RequestParam("ids") Long[] ids,
        @PathVariable("newStatus") UserStatus newStatus,
        @RequestParam("reason") String reason,
        @CurrentUser User opUser,
        RedirectAttributes redirectAttributes) {

    getUserService().changeStatus(opUser, ids, newStatus, reason);

    if (newStatus == UserStatus.normal) {
        redirectAttributes.addFlashAttribute(Constants.MESSAGE, "解封成功!");
    } else if (newStatus == UserStatus.blocked) {
        redirectAttributes.addFlashAttribute(Constants.MESSAGE, "封禁成功!");
    }

    return redirectToUrl((String) request.getAttribute(Constants.BACK_URL));
}
 
Example #21
Source File: PasswordChangeController.java    From zhcet-web with Apache License 2.0 6 votes vote down vote up
@PostMapping
public String savePassword(@Valid PasswordChange passwordChange, BindingResult bindingResult, RedirectAttributes redirectAttributes) {
    User user = userService.getLoggedInUser().orElseThrow(UserNotFoundException::new);

    if (bindingResult.hasErrors()) {
        redirectAttributes.addFlashAttribute("password", passwordChange);
        redirectAttributes.addFlashAttribute("org.springframework.validation.BindingResult.password", bindingResult);
    } else  {
        try {
            passwordChangeService.changePassword(user, passwordChange);
            redirectAttributes.addFlashAttribute("flash_messages", Flash.success("Password was changed successfully"));
            return "redirect:/profile/settings#account";
        } catch (PasswordValidationException pve) {
            redirectAttributes.addFlashAttribute("pass_errors", pve.getMessage());
        }
    }

    return "redirect:/profile/password/change";
}
 
Example #22
Source File: Mario_plugin_infoController.java    From Mario with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "create", method = RequestMethod.POST)
public String create(@Valid Mario_plugin_info newMario_plugin_info,
		BindingResult result, Model model,
		RedirectAttributes redirectAttributes) {
	if (result.hasErrors()) {
		model.addAttribute("action", "create");
		List<Mario_zk_info> mario_zk_infoList = zkInfoService
				.getAllMario_zk_info();
		Page<Mario_zk_info> mario_zk_infos = new PageImpl<Mario_zk_info>(
				mario_zk_infoList,
				new PageRequest(0, mario_zk_infoList.size()),
				mario_zk_infoList.size());
		model.addAttribute("mario_zk_infos", mario_zk_infos);
		return "mario_plugin_info/mario_plugin_infoForm";
	}
	if (zkInfoService.getMario_zk_info(newMario_plugin_info.getzk_id()) == null) {
		redirectAttributes.addFlashAttribute("alertType", "alert-danger");
		redirectAttributes.addFlashAttribute("message", "集群已经不存在");			
	} else {
		service.saveMario_plugin_info(newMario_plugin_info);
		redirectAttributes.addFlashAttribute("alertType", "alert-success");
		redirectAttributes.addFlashAttribute("message", "创建成功");
	}
	return "redirect:/mario_plugin_info/";
}
 
Example #23
Source File: PostsController.java    From yfshop with Apache License 2.0 6 votes vote down vote up
/**
 * 保存文章
 *
 * @param tbPostsPost
 * @return
 */
@RequestMapping(value = "save", method = RequestMethod.POST)
public String save(TbPostsPost tbPostsPost, HttpServletRequest request, RedirectAttributes redirectAttributes) throws Exception {
    // 初始化
    tbPostsPost.setTimePublished(new Date());
    tbPostsPost.setStatus("0");

    TbSysUser admin = (TbSysUser) request.getSession().getAttribute(WebConstants.SESSION_USER);
    String tbPostsPostJson = MapperUtils.obj2json(tbPostsPost);
    String json = postsService.save(tbPostsPostJson, admin.getUserCode());
    BaseResult baseResult = MapperUtils.json2pojo(json, BaseResult.class);

    redirectAttributes.addFlashAttribute("baseResult", baseResult);
    if (baseResult.getSuccess().endsWith("成功")) {
        return "redirect:/index";
    }
    return "redirect:/form";
}
 
Example #24
Source File: EventRouteController.java    From konker-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping(path = "/{applicationName}/{routeGUID}", method = RequestMethod.PUT)
@PreAuthorize("hasAuthority('EDIT_DEVICE_ROUTE')")
public ModelAndView saveEdit(@PathVariable("applicationName") String applicationName,
							 @PathVariable String routeGUID,
                             @ModelAttribute("eventRouteForm") EventRouteForm eventRouteForm,
                             RedirectAttributes redirectAttributes, Locale locale) {
    Application application = applicationService.getByApplicationName(tenant, applicationName).getResult();

    return doSave(tenant,
                  application,
                  () -> {
                        eventRouteForm.setAdditionalSupplier(() -> tenant.getDomainName());
                        return eventRouteService.update(tenant, application, routeGUID, eventRouteForm.toModel());
                  },
                  eventRouteForm,
                  locale,
                  redirectAttributes,
                  "put");

}
 
Example #25
Source File: EventRouteController.java    From konker-platform with Apache License 2.0 6 votes vote down vote up
@RequestMapping(path = "/{applicationName}/save", method = RequestMethod.POST)
@PreAuthorize("hasAuthority('CREATE_DEVICE_ROUTE')")
public ModelAndView save(@PathVariable("applicationName") String applicationName,
						 @ModelAttribute("eventRouteForm") EventRouteForm eventRouteForm,
                         RedirectAttributes redirectAttributes, Locale locale) {

    Application application = applicationService.getByApplicationName(tenant, applicationName).getResult();

    return doSave(tenant,
                  application,
                  () -> {
                        eventRouteForm.setAdditionalSupplier(() -> tenant.getDomainName());
                        return eventRouteService.save(tenant, application, eventRouteForm.toModel());
                  },
                  eventRouteForm,
                  locale,
                  redirectAttributes,
                  "");

}
 
Example #26
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 反签收任务
 */
@RequestMapping(value = "task/unclaim/{id}")
public String unclaim(@PathVariable("id") String taskId, HttpSession session, RedirectAttributes redirectAttributes) {
    // 反签收条件过滤
    List<IdentityLink> links = taskService.getIdentityLinksForTask(taskId);
    for (IdentityLink identityLink : links) {
        // 如果一个任务有相关的候选人、组就可以反签收
        if (StringUtils.equals(IdentityLinkType.CANDIDATE, identityLink.getType())) {
            taskService.claim(taskId, null);
            redirectAttributes.addFlashAttribute("message", "任务已反签收");
            return TASK_LIST;
        }
    }
    redirectAttributes.addFlashAttribute("error", "该任务不允许反签收!");
    return TASK_LIST;
}
 
Example #27
Source File: GroupController.java    From base-framework with Apache License 2.0 6 votes vote down vote up
/**
 * 
 * 保存或更新组,保存成功后重定向到:account/group/view
 * 
 * @param entity 实体信息
 * @param request HttpServletRequest
 * @param redirectAttributes spring mvc 重定向属性
 * 
 * @return String
 */
@RequestMapping("save")
@OperatingAudit(function="保存或更新组")
public String save(@ModelAttribute("entity") Group entity,HttpServletRequest request,RedirectAttributes redirectAttributes) {
	
	String parentId = request.getParameter("parentId");
	
	if (StringUtils.isEmpty(parentId)) {
		entity.setParent(null);
	} else {
		entity.setParent(accountManager.getGroup(parentId));
	}
	
	List<String> resourceIds = ServletUtils.getParameterValues(request, "resourceId");
	
	entity.setResourcesList(accountManager.getResources(resourceIds));
	
	accountManager.saveGroup(entity);
	redirectAttributes.addFlashAttribute("success", "保存成功");
	return "redirect:/account/group/view";
}
 
Example #28
Source File: IdentityController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 保存User
 *
 * @param redirectAttributes
 * @return
 */
@RequestMapping(value = "user/save", method = RequestMethod.POST)
public String saveUser(@RequestParam("userId") String userId,
                       @RequestParam("firstName") String firstName,
                       @RequestParam("lastName") String lastName,
                       @RequestParam(value = "password", required = false) String password,
                       @RequestParam(value = "email", required = false) String email,
                       RedirectAttributes redirectAttributes) {
    User user = identityService.createUserQuery().userId(userId).singleResult();
    if (user == null) {
        user = identityService.newUser(userId);
    }
    user.setFirstName(firstName);
    user.setLastName(lastName);
    user.setEmail(email);
    if (StringUtils.isNotBlank(password)) {
        user.setPassword(password);
    }
    identityService.saveUser(user);
    redirectAttributes.addFlashAttribute("message", "成功添加用户[" + firstName + " " + lastName + "]");
    return "redirect:/chapter14/identity/user/list";
}
 
Example #29
Source File: SystemIndexController.java    From wallride with Apache License 2.0 6 votes vote down vote up
@Transactional(propagation = Propagation.REQUIRED)
@RequestMapping(value = "/clear-cache", method = RequestMethod.POST)
public String clearCache(
		@PathVariable String language,
		RedirectAttributes redirectAttributes,
		HttpServletRequest request,
		HttpServletResponse response) throws Exception {

	WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext, "org.springframework.web.servlet.FrameworkServlet.CONTEXT.guestServlet");
	if (context == null) {
		throw new ServiceException("GuestServlet is not ready yet");
	}

	DefaultModelAttributeInterceptor interceptor = context.getBean(DefaultModelAttributeInterceptor.class);
	ModelAndView mv = new ModelAndView("dummy");
	interceptor.postHandle(request, response, this, mv);

	SpringTemplateEngine templateEngine = context.getBean("templateEngine", SpringTemplateEngine.class);
	logger.info("Clear cache started");
	templateEngine.clearTemplateCache();
	logger.info("Clear cache finished");

	redirectAttributes.addFlashAttribute("clearCache", true);
	redirectAttributes.addAttribute("language", language);
	return "redirect:/_admin/{language}/system";
}
 
Example #30
Source File: BetController.java    From fredbet with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
@PostMapping
public String saveBet(@Valid BetCommand betCommand, BindingResult bindingResult, RedirectAttributes redirect) {
    if (bindingResult.hasErrors()) {
        return VIEW_EDIT;
    }

    try {
        bettingService.save(toBet(betCommand));
        messageUtil.addInfoMsg(redirect, "msg.bet.betting.created");
    } catch (NoBettingAfterMatchStartedAllowedException e) {
        messageUtil.addErrorMsg(redirect, "msg.bet.betting.error.matchInProgress");
    }

    String view = RedirectViewName.resolveRedirect(betCommand.getRedirectViewName());
    return view + "#" + betCommand.getMatchId();
}