Results 1 to 4 of 4

Thread: Neither Errors instance nor plain target object for bean name 'reg' available as requ

Hybrid View

  1. #1
    Join Date
    Aug 2008
    Posts
    109

    Default Neither Errors instance nor plain target object for bean name 'reg' available as requ

    There are lot of posts in this regard. But mine looks bit strange.

    The moment i include the below two lines after form tag in my jsp, the above error occurs upon loading of registration page.

    Code:
     <font color="red"><form:errors path="regEmail" /></font>
                 <font color="red"><form:errors path="regPasswd" /></font>
    My form tag is as below:

    Code:
    <portlet:actionURL var="aURL">
            <portlet:param name="action" value="registration"/>
    </portlet:actionURL>
    
    <form:form commandName="reg" method="post" action="${aURL}" enctype="application/x-www-form-urlencoded">
    My controller code is as given below:

    Code:
    public class RegistrationController extends SimpleFormController {
    
        public RegistrationController() { }
        
        private RegistrationService regService;
    
        @Override
        protected void onSubmitAction(ActionRequest request, ActionResponse response, Object command, BindException arg3) throws Exception {
            System.out.println("Entering RegistrationController -> onSubmitAction");
            Registration regObj = (Registration) command;           
            
            System.out.println("values from request object are -----> " + regObj.getRegFirstName() + ", " + regObj.getRegLastName() + ", " + regObj.getRegEmail() + ", " + regObj.getRegPasswd());
            boolean flag = regService.performRegistration(regObj);
            if(!flag) {     
                throw new Exception("User Id already exists!! Please select different user id.");
            }
            System.out.println("Leaving RegistrationController -> onSubmitAction");
            response.setRenderParameter("action","regsuccess");
        }
        
    
       public ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception {
            System.out.println("ENtering RegistrationController -> handleRenderRequestInternal");
            System.out.println("Leaving RegistrationController -> handleRenderRequestInternal");
            return new ModelAndView("registration");
        }
    
    
        public void setRegService(RegistrationService regService) {
            this.regService = regService;
        }
    
    }
    Can somebody help me resolve the above error? Thanks so much for any help.

  2. #2
    Join Date
    Oct 2006
    Posts
    228

    Default

    Have you set the command name on the controller to be "reg"?

    If so, then please post the stacktrace, spring config, and command class.

    Chris

  3. #3
    Join Date
    Oct 2006
    Posts
    228

    Default

    Oh right just realised you have overriden handleRenderRequestInternal, this means you are overriding most of the behaviour of the SimpleFormController. In general when using a SimpleFormController you just specify the successView property and this is automatically used for rendering once the form has been submitted and validate successfully, this is no need to handle the render phase explictly in your controller. If you need more control then their are other methods you are override as documented in the SimpleFormController javadoc.

  4. #4
    Join Date
    Aug 2008
    Posts
    109

    Default

    Thanks Chris. Info was really helpful.

    I commented the 'handleRenderRequestInternal' method in the controller and put the below two lines in spring config (formView and successView). Everything worked just fine.

    Code:
    <property name="formView" value="registration" />
                    <property name="successView" value="regsuccess" />
    Thanks so much. Appreciate your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •