Validaton(Checking Blank space)

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 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>
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
Java textfield validaton
Java textfield validaton
UItextfield blank
UItextfield blank  Hi, How I can check if UITextfield is blank and then display error to the user? ThanksADS_TO_REPLACE_1   Hi, Following code can be used to validate the user input in iPhone and iPad applications
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,ADS_TO_REPLACE_1 here is some code for textfield checking if ([name.text isEqualToString:@"hello
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
Remove Extra Space At End
Remove Extra Space At End  Remove Extra Space At End
time and space complexity
time and space complexity  sort the data structures according to efficient time and space utilisation
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
ModuleNotFoundError: No module named 'space'
ModuleNotFoundError: No module named 'space'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'space' How to remove the ModuleNotFoundError: No module named 'space'
ModuleNotFoundError: No module named 'checking'
ModuleNotFoundError: No module named 'checking'  Hi, My Python... 'checking' How to remove the ModuleNotFoundError: No module named 'checking... to install padas library. You can install checking python with following
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
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
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
java.lang.OutOfMemoryError: Java heap space
" java.lang.OutOfMemoryError: Java heap space How to resolve this issue? Thanks   Hi... your program. Check the thread Java heap space and java.lang.OutOfMemoryError: Java heap space. Thanks
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
org.apache.myfaces.tobago - tobago-example-blank version 1.5.13 Maven dependency. How to use tobago-example-blank version 1.5.13 in pom.xml?
org.apache.myfaces.tobago  - Version 1.5.13 of tobago-example-blank Maven... of tobago-example-blank in pom.xml? How to use tobago-example-blank version...-blank in project by the help of adding the dependency in the pom.xml file
org.apache.myfaces.tobago - tobago-example-blank version 1.0.31 Maven dependency. How to use tobago-example-blank version 1.0.31 in pom.xml?
org.apache.myfaces.tobago  - Version 1.0.31 of tobago-example-blank Maven... of tobago-example-blank in pom.xml? How to use tobago-example-blank version...-blank in project by the help of adding the dependency in the pom.xml file
org.apache.myfaces.tobago - tobago-example-blank version 4.1.0 Maven dependency. How to use tobago-example-blank version 4.1.0 in pom.xml?
org.apache.myfaces.tobago  - Version 4.1.0 of tobago-example-blank Maven... of tobago-example-blank in pom.xml? How to use tobago-example-blank version 4.1.0... to use org.apache.myfaces.tobago  - Version 4.1.0 of tobago-example-blank
org.apache.myfaces.tobago - tobago-example-blank version 2.4.5 Maven dependency. How to use tobago-example-blank version 2.4.5 in pom.xml?
org.apache.myfaces.tobago  - Version 2.4.5 of tobago-example-blank Maven... of tobago-example-blank in pom.xml? How to use tobago-example-blank version 2.4.5... to use org.apache.myfaces.tobago  - Version 2.4.5 of tobago-example-blank
org.apache.myfaces.tobago - tobago-example-blank version 2.4.5 Maven dependency. How to use tobago-example-blank version 2.4.5 in pom.xml?
org.apache.myfaces.tobago  - Version 2.4.5 of tobago-example-blank Maven... of tobago-example-blank in pom.xml? How to use tobago-example-blank version 2.4.5... to use org.apache.myfaces.tobago  - Version 2.4.5 of tobago-example-blank
org.apache.myfaces.tobago - tobago-example-blank version 1.0.37 Maven dependency. How to use tobago-example-blank version 1.0.37 in pom.xml?
org.apache.myfaces.tobago  - Version 1.0.37 of tobago-example-blank Maven... of tobago-example-blank in pom.xml? How to use tobago-example-blank version...-blank in project by the help of adding the dependency in the pom.xml file
org.apache.myfaces.tobago - tobago-example-blank version 1.0.37 Maven dependency. How to use tobago-example-blank version 1.0.37 in pom.xml?
org.apache.myfaces.tobago  - Version 1.0.37 of tobago-example-blank Maven... of tobago-example-blank in pom.xml? How to use tobago-example-blank version...-blank in project by the help of adding the dependency in the pom.xml file
java.lang.OutOfMemoryError: Java heap space
java.lang.OutOfMemoryError: Java heap space error. This error is coming while... java.lang.OutOfMemoryError: Java heap space where there is no more space available... space using following parameters while starting your application: While running
python replace newline with space
python replace newline with space  Hi, I want to replace newline character \n With space in python. How to replace newline with space in python? Thanks   Hi, Its easy in python. You can use the replace method
python replace newline with space
python replace newline with space  Hi, I want to replace newline character \n With space in python. How to replace newline with space in python? Thanks   Hi, Its easy in python. You can use the replace method
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
space around/between my images
space around/between my images  How do I eliminate the space around/between my images
how to space images in html code
how to space images in html code  how to space images in html code
Hibernate Dirty Checking
This section contains the concept of Hibernate dirty checking
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
ModuleNotFoundError: No module named 'assoc_space'
ModuleNotFoundError: No module named 'assoc_space'  Hi, My Python... 'assoc_space' How to remove the ModuleNotFoundError: No module named 'assoc_space' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'coverage-space'
ModuleNotFoundError: No module named 'coverage-space'  Hi, My... named 'coverage-space' How to remove the ModuleNotFoundError: No module named 'coverage-space' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'py_space'
ModuleNotFoundError: No module named 'py_space'  Hi, My Python..._space' How to remove the ModuleNotFoundError: No module named 'py_space... to install padas library. You can install py_space python with following
ModuleNotFoundError: No module named 'python-space'
ModuleNotFoundError: No module named 'python-space'  Hi, My Python... 'python-space' How to remove the ModuleNotFoundError: No module named 'python-space' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sample_space'
ModuleNotFoundError: No module named 'sample_space'  Hi, My Python... 'sample_space' How to remove the ModuleNotFoundError: No module named 'sample_space' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'space-aliens'
ModuleNotFoundError: No module named 'space-aliens'  Hi, My Python... 'space-aliens' How to remove the ModuleNotFoundError: No module named 'space-aliens' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'space-api'
ModuleNotFoundError: No module named 'space-api'  Hi, My Python... 'space-api' How to remove the ModuleNotFoundError: No module named 'space... have to install padas library. You can install space-api python with following
ModuleNotFoundError: No module named 'space-bandits'
ModuleNotFoundError: No module named 'space-bandits'  Hi, My... 'space-bandits' How to remove the ModuleNotFoundError: No module named 'space-bandits' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'space-command'
ModuleNotFoundError: No module named 'space-command'  Hi, My... 'space-command' How to remove the ModuleNotFoundError: No module named 'space-command' error? Thanks   Hi, In your python

Ads