anjanks1981
Jun 5th, 2008, 04:34 PM
I have a Student bean with name, email and phone number. I am using Java 1.4 with RAD 6.0. There are no compilation or run time errors that I see. I have written a validator for Student and it is being accessed and error messages are displayed in the console saying that name is empty if I don't enter the name.
However, I am not able to display this in JSP although I have used <spring:bind>
//In validator
public void validate(Object command,Errors errors)
{
Student student = (Student)command;
ValidationUtils.rejectIfEmpty(errors,"name","requi red.name","Name is required");
ValidationUtils.rejectIfEmpty(errors,"email","requ ired.email","Email is required");
ValidationUtils.rejectIfEmpty(errors,"phoneNumber" ,"required.phoneNumber","Phone Number is required");
}
In JSP,
<spring:bind path="student.name">
<input type="text" name="name" value="${status.value}" />
</spring:bind>
<spring:hasBindErrors name="student">
<font color="red">${status.errorMessage}</font>
</spring:hasBindErrors>
In configuration file for Spring
<bean id="getSubjectsController"
class="com.assurant.GetSubjectsController">
<property name="formView">
<value>InputName</value>
</property>
<property name="successView">
<value>OutputSubjects</value>
</property>
<property name="commandName"><value>student</value></property>
<property name="commandClass"><value>com.assurant.Student</value></property>
<property name="validator">
<bean class="com.assurant.StudentValidator" />
</property>
</bean>
I see no errors and Validation is being accessed correctly when I don't enter anything for "name". But why the error message which I see on console is not visible in JSP?
I had followed the link posted[/url] on the forum..but not working
However, I am not able to display this in JSP although I have used <spring:bind>
//In validator
public void validate(Object command,Errors errors)
{
Student student = (Student)command;
ValidationUtils.rejectIfEmpty(errors,"name","requi red.name","Name is required");
ValidationUtils.rejectIfEmpty(errors,"email","requ ired.email","Email is required");
ValidationUtils.rejectIfEmpty(errors,"phoneNumber" ,"required.phoneNumber","Phone Number is required");
}
In JSP,
<spring:bind path="student.name">
<input type="text" name="name" value="${status.value}" />
</spring:bind>
<spring:hasBindErrors name="student">
<font color="red">${status.errorMessage}</font>
</spring:hasBindErrors>
In configuration file for Spring
<bean id="getSubjectsController"
class="com.assurant.GetSubjectsController">
<property name="formView">
<value>InputName</value>
</property>
<property name="successView">
<value>OutputSubjects</value>
</property>
<property name="commandName"><value>student</value></property>
<property name="commandClass"><value>com.assurant.Student</value></property>
<property name="validator">
<bean class="com.assurant.StudentValidator" />
</property>
</bean>
I see no errors and Validation is being accessed correctly when I don't enter anything for "name". But why the error message which I see on console is not visible in JSP?
I had followed the link posted[/url] on the forum..but not working