Java Code Examples for org.springframework.validation.BindingResult#getSuppressedFields()

The following examples show how to use org.springframework.validation.BindingResult#getSuppressedFields() . 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: ProductController.java    From maven-framework-project with MIT License 6 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") Product productToBeAdded, ModelMap map, BindingResult result, HttpServletRequest request) {
	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 2
Source File: ProductController.java    From maven-framework-project with MIT License 6 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") Product productToBeAdded, ModelMap map, BindingResult result, HttpServletRequest request) {
	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 3
Source File: ProductController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product productToBeAdded, BindingResult result, HttpServletRequest request) {
	if(result.hasErrors()) {
		return "addProduct";
	}

	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 4
Source File: ProductController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product productToBeAdded, BindingResult result, HttpServletRequest request) {
	if(result.hasErrors()) {
		return "addProduct";
	}

	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 5
Source File: ProductController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product productToBeAdded, BindingResult result, HttpServletRequest request) {
	if(result.hasErrors()) {
		return "addProduct";
	}

	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 6
Source File: ProductController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product productToBeAdded, BindingResult result, HttpServletRequest request) {
	if(result.hasErrors()) {
		return "addProduct";
	}

	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 7
Source File: ProductController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product productToBeAdded, BindingResult result, HttpServletRequest request) {
	if(result.hasErrors()) {
		return "addProduct";
	}

	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 8
Source File: ProductController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") Product productToBeAdded, ModelMap map, BindingResult result) {
	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}
 
Example 9
Source File: ProductController.java    From maven-framework-project with MIT License 5 votes vote down vote up
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String processAddNewProductForm(@ModelAttribute("newProduct") @Valid Product productToBeAdded, BindingResult result, HttpServletRequest request) {
	if(result.hasErrors()) {
		return "addProduct";
	}

	String[] suppressedFields = result.getSuppressedFields();
	
	if (suppressedFields.length > 0) {
		throw new RuntimeException("Attempting to bind disallowed fields: " + StringUtils.arrayToCommaDelimitedString(suppressedFields));
	}
	
	MultipartFile productImage = productToBeAdded.getProductImage();
	String rootDirectory = request.getSession().getServletContext().getRealPath("/");
			
		if (productImage!=null && !productImage.isEmpty()) {
	       try {
	      	productImage.transferTo(new File(rootDirectory+"resources\\images\\"+productToBeAdded.getProductId() + ".png"));
	       } catch (Exception e) {
			throw new RuntimeException("Product Image saving failed", e);
	   }
	   }

	
   	productService.addProduct(productToBeAdded);
	return "redirect:/products";
}