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) - SpringValidaton(
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 Beginnersblank 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 blankUItextfield 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 uploadPHP 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 checkingUITextfield 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 datachecking 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 - StrutsStruts2
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
Running problem with NoughtsAndCrossesGame in blankRunning 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
time and space complexitytime and
space complexity sort the data structures according to efficient time and
space utilisation
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
Dirty Checking In Hibernate ExampleDirty
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 ExampleDirty
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 FieldMySQL
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 statementchecking 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 elswhereJust
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.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 spacepython 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 spacepython 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 javaxmlname
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
Java heap spaceJava 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 '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 '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