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



Home Answers Viewqa Spring Validaton(Checking Blank space)

Have Programming Question? Ask it here!
 
 
 


rajib dihingia
Validaton(Checking Blank space)
0 Answer(s)      4 years and 5 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
Advertisements
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
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
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
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
Remove Extra Space At End
Remove Extra Space At End  Remove Extra Space At End
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
Hibernate Dirty Checking
This section contains the concept of Hibernate dirty checking
time and space complexity
time and space complexity  sort the data structures according to efficient time and space utilisation
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
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
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 Classpath Validity - Java Tutorials
Checking Classpath Validity 2001-12-13 The Java Specialists' Newsletter [Issue 037] - Checking that your classpath is valid Author: Sydney Redelinghuys..., let's see what Sydney, the one-legged Java Guru has to say ... Checking Your
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
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
Creating Blank DOM Document
Creating Blank DOM Document       This tutorial shows you how to create blank DOM document. JAXP (Java... of the class DocumentBuilder is used to create a blank document. The newDocument
Checking the decimal whether comma used or not
Checking the decimal whether comma used or not  I need to check the given integer whther comma used or not. For example. If the user given 123456 The output should be like 123,456 If the user given 123,456 The output should
stock checking in java with backend as access
stock checking in java with backend as access  Hi, I am doing a project in java,Can i able to know how to check the stock availability of a product in java...my back end connectivity is ms-access from the database ,i hv
how to space images in html code
how to space images in html code  how to space images in html code
space around/between my images
space around/between my images  How do I eliminate the space around/between my images
Checking whether a year is leap or not
Checking whether a year is leap or not       This tutorial is going to teach you the coding for checking whether a year is a leap year or not. Here, we have taken the year 2000. So
Dirty Checking In Hibernate
Dirty Checking In Hibernate In this section we will read about the dirty checking in hibernate. Dirty Checking is the feature of hibernate that helps... for dirty checking. In an inspection strategy, a snapshot of the object
space between buttons iPhone SDK
space between buttons iPhone SDK  Hi, can any one please explain how to add space between UIButtons in iPhone SDK. Actually i am creating Multiple UIButton's and added them to my UIScrollView. But problem is that those buttons
White Space encoding problem in PDF
White Space encoding problem in PDF  I am reading PDF version 1.3 using iText. Things are fine but with one problem that is I am not able to get whitespace. Is there any problem in whitespace encoding in PDF version 1.3
Find total disk space in PHP, php disk_total_space, disk_total_space
Learn How to Get the total disk space in PHP Program. In this PHP Tutorial example we will use the disk_total_space() function in our PHP code to find the total disk space. syntax disk_total_space() Function PHP disk_total_space
there extra space before or after my table.
there extra space before or after my table.  Why is there extra space before or after my table
eliminate the extra space after a </form> tag
eliminate the extra space after a tag  How can I eliminate the extra space after a tag
using java.lang.OutOfMemoryError: Java heap space
and my program has this error "using java.lang.OutOfMemoryError: Java heap space
Display free disk space
Description: This example will demonstrate how to get the free disk space... in java.io.File. This method get the free disk space in the bytes. Code... upon number of drive you have and the free space available. Note
PHP find free space, php disk_free_space, disk_free_space
The example Shows of disk_free_space() function in php Program. In this section you will find the example code of disk_free_space() function. The disk_free_space() function in PHP is used to find the Hard Disk's free space from
java heap space & netbeans - Java Beginners
java heap space & netbeans  Java heap space". I'm using netbeans 5.1.1 and jdk1.5.0_07 version.. can any body say how can i know the amount of java heap space while i run...java heap space & netbeans Hey,all!! I've got a problem
Checking elsewhere with correctly blocked code and question
Checking elsewhere with correctly blocked code and question  Hi I have already posted this question but realised I had made a few mistakes. So firstly the problem again!. I have a textarea box for user comments which will return
Advertisements
 

 

 

DMCA.com