Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Spring Validaton(Checking Blank space)
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


rajib dihingia
Validaton(Checking Blank space)
0 Answer(s)      4 years and 10 months ago
Posted in : Spring


Hi i am using java springs .I am having problem in doing validation.
I am just checking blank space.

This is my controller. I named it salescontroller.

package controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import validator.DepartmentValidator;
import com.Department;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import manager.DeptDaoImp;
import manager.DeptDao;
import java.io.IOException;

@Controller
public class salescontroller {
private DepartmentValidator departmentValidator;
public salescontroller(DepartmentValidator departmentValidator) {
this.departmentValidator=this.departmentValidator;
}
@RequestMapping("/Department.htm")
public String showDepartment(ModelMap model){
model.addAttribute("Department",new Department());
return "Department";
}
@RequestMapping("/Departmentdo.htm")
public String onSubmit(@ModelAttribute("Department")Department d, BindingResult result, HttpServletResponse response)
throws ServletException, IOException {
departmentValidator.validate(d,result);
if(result.hasErrors())
{
return "Department";
}
return "Department";

}
}
And this is my Validator I named it DepartmentValidator
public class DepartmentValidator implements Validator {
public boolean supports(Class clazz) {
return Department.class.isAssignableFrom(clazz);
}

public void validate(Object target, Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "",
"department_ID.required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "department_name",
"department_name.required");
ValidationUtils.rejectIfEmpty(errors, "description", "description.required");
}
}


This is my Dispatcher-servlet

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean name="/Department.htm" class="controller.salescontroller"/>
</beans>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Validaton(Checking Blank space) - Spring
Validaton(Checking Blank space)  Hi i am using java springs .I am having problem in doing validation. I am just checking blank space. This is my controller. I named it salescontroller. package controller; import
blank space in input field - Java Beginners
blank space in input field  I retrieved the fields from my mysql table...If the field contains null value i want to display a blank space in input field(text box)..but i am displaying null how to overcome this.. u r help
Advertisements
UItextfield blank
UItextfield blank  Hi, How I can check if UITextfield is blank and then display error to the user? Thanks   Hi, Following code can be used to validate the user input in iPhone and iPad applications. if([loginID.text
PHP Prevent blank upload
PHP Prevent blank upload  In my small PHP application, i am posting... is that it also accepts blank data as well as duplicate value. Is there any way to check and prevent it from posting the blank value? Thanks
UITextfield checking
UITextfield checking  hello,, how can i check UITextfield length or any specific value..   hii, here is some code for textfield checking if ([name.text isEqualToString:@"hello"]) or if (name.text.length<1
checking the data
checking the data  Sir, I have built an application where a user types a long string as input. Then after he/she types a single word of that string. I'm supposed to show all strings which have that word in them. Ex. the string
Struts2 blank application - Struts
Struts2 blank application  Hi I am new to struts2 and i am trying to run the strutsblank application by following the following Link; http://www.roseindia.net/struts/struts2/index.shtml As per the instructions given
How to design a blank CD, design a blank CD, blank CD
How to design a blank CD       This is a blank CD example, You will learn here how to make a blank CD by taking help of this example. New File: Take a new file with any
Running problem with NoughtsAndCrossesGame in blank
Running problem with NoughtsAndCrossesGame in blank  Hi i was having problem created NoughtsAndCrossesGame in end the it works but i runs the gui in blank. Its another way to solve it /* * To change this template, choose
Dirty Checking In Hibernate Example
Dirty Checking In Hibernate Example  What is the example of Dirty Checking in Hibernate? Give me some of the example code? Thanks
php dynamic array checking
php dynamic array checking  php dynamic array checking
php dynamic array checking
php dynamic array checking  php dynamic array checking
Dirty Checking In Hibernate Example
Dirty Checking In Hibernate Example  Hi, What is Dirty Checking... Checking In Hibernate is an mechanism for automatically detects the changes in the state of an Entity. Check tutorial at Dirty Checking In Hibernate section
Dirty Checking In Hibernate Example
Dirty Checking In Hibernate Example  What is the example of Dirty Checking in Hibernate? Give me some of the example code? Thanks   The Dirty Checking In Hibernate is used to track the status of the entity and detect
Dirty checking feature of hibernate.
Dirty checking feature of hibernate.  What is the dirty checking feature of Hibernate?   Hi friends, Dirty checking is a feature of hibernate. It allows the user or developer to avoid the time consuming databases
Remove Extra Space At End
Remove Extra Space At End  Remove Extra Space At End
MySQL Blank Field
MySQL Blank Field This example illustrates how to find Blank field by the MySQL Query. In the table 'example' two t_count fields are blank and we find both field which has some value by query 'select * from example where t_count
checking index in prepared statement
checking index in prepared statement  If we write as follows: String query = "insert into st_details values(?,?,?)"; PreparedStatement ps = con.prepareStatement(query); then after query has been prepared, can we check the index
time and space complexity
time and space complexity  sort the data structures according to efficient time and space utilisation
Hibernate Dirty Checking
This section contains the concept of Hibernate dirty checking
Just checking elswhere
Just checking elswhere  I have been posting some questions within the HTML group but getting no joy. I thought I would try another area. The main question I was looking for is: I have a textarea box which post a single users
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space error. This error is coming while...: Java heap space where there is no more space available for the Java program... space. You can also increase the Java heap space using following parameters
Program to Ignore Space and Enter ?!
Program to Ignore Space and Enter ?!  Hi, dear friend i wont to write program to enter many statements, if i use Space and Enter in the Run Time must be delete the space and ignore the Enter ..for example if i entered
What is the dirty checking feature of Hibernate?
What is the dirty checking feature of Hibernate?  What is the dirty checking feature of Hibernate?   Hibernate allows dirty checking... process of updating the changed object is called automatic dirty checking. Dirty
xmlname space in java
xmlname space in java  hi i want to write code like , i used setAttribute method for this. but its showing ERROR: 'Namespace for prefix 'company' has not been declared.' javax.xml.transform.TransformerException
Checking the CustomItem in j2me support traversal or not?
Checking the CustomItem in j2me support traversal or not?  Hi, How should i check the CustomItem in j2me support traversal or not. Thanks & Regards, Sivakumar.J
Java heap space
Java heap space  I am using MyEclipse 8.6 for my web based project. The command may be... Ex: java -Xms32m -Xmx128m How can I increase java heap space??? and Where to use this command exactly?   Following are few
Error in checking null value in string
Error in checking null value in string  Error in checking null value in string Hi am getting Exception : java.lang.NullPointerException in the following code: String registerno=null; registerno=request.getParameter("registerno
how to space images in html code
how to space images in html code  how to space images in html code
 

 

 

DMCA.com