Dear friends,
I am trying to validation with MultiActionController, Could anyone help me in this regard?
Could anyone have sample code how to do validation with MultiActionController?
----------
I am doing sample 'phonebook' application using MultiActionController, here is my code,
public class PhoneBookController extends MultiActionController
{
public ModelAndView newcontactHandler(HttpServletRequest request, HttpServletResponse response)
{
try
{
Contact newContact = (Contact)newCommandObject(Contact.class);
bind(request, newContact);
phoneBook.addNewContact(newContact);
return new ModelAndView("add-success");
}
catch(Exception e){}
}
}
-----------------------------------
here is my bean definition file,
<bean id="phoneBookController" class="controller.PhoneBookController">
<property name="methodNameResolver" ref="internalPathMethodNameResolver"/>
<property name="phoneBook" ref="phoneBook"/>
<property name="validators" ref="contactInfoValidator"/>
</bean>
<bean id="contactInfoValidator" class="validator.ContactInfoValidator"/>
but I am getting the following error,******************
org.springframework.web.bind.ServletRequestBinding Exception: Errors binding onto object 'command'; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBinding Result: 2 errors
Field error in object 'command' on field 'contactName': rejected value []; codes [contactName.emptyerror.command.contactName,contact Name.emptyerror.contactName,contactName.emptyerror .java.lang.String,contactName.emptyerror]; arguments []; default message [null]
Field error in object 'command' on field 'phoneNumber': rejected value []; codes [phoneNumber.emptyerror.command.phoneNumber,phoneNu mber.emptyerror.phoneNumber,phoneNumber.emptyerror .java.lang.String,phoneNumber.emptyerror]; arguments []; default message [null]


Reply With Quote