Announcement Announcement Module
Collapse
No announcement yet.
Neither BindingResult nor plain target object for bean name '' available as request Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neither BindingResult nor plain target object for bean name '' available as request

    Hi all,

    I am using AbstractWizardFormController and I am trying to update (add a list of objects) the command object in the postProcessPage, but it gives the error.

    Can some one help me on what's wrong in this code ?

    Controller class

    Code:
    public class NewOrderController  extends AbstractWizardFormController {
    
    	private HotelService hs;
    	public NewOrderController() {
    		setCommandName("orderForm");
    		setPages(new String[] {"step1", "step2", "step3"});
    	}
    
    	protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
    		return new OrderForm();
    	}
    
    	protected void postProcessPage(HttpServletRequest request, Object command, Errors errors, int page) throws Exception {
    		System.out.println(">>>!!!!!<<<<<< postProcessPage page="+page);
    		if(page==0){
    			OrderForm form = (OrderForm) command; 
    			List list = new ArrayList();
    			list.add(new AvailableRoomsForm(hs.getAllFreeRooms()));
    			form.setAvailableRooms(list);
    		}
    	}
    	
    ...
    	protected void validatePage(Object command, Errors errors, int page) {
    }
    
    	protected ModelAndView processFinish(
    			HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) {
    ...
    }
    }
    And JSP's are like normal display with spring:binding.

    This is the error detail:

    Code:
    org.apache.jasper.JasperException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name '' available as request attribute
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:413)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1031)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:815)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    
    
    root cause 
    
    java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name '' available as request attribute
    	org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:147)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:138)
    	org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:122)
    	org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:408)
    	org.springframework.web.servlet.tags.form.SelectTag.writeTagContent(SelectTag.java:198)
    	org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
    	org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
    	org.apache.jsp.WEB_002dINF.jsp.step2_jsp._jspService(step2_jsp.java:809)
    	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
    	org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    	org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1031)
    	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:815)
    	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

  • #2
    well the exception is being thrown while compiling the JSP, so i think it would be best if you could post your JSP here.

    Comment


    • #3
      Thanks for point out the JSP issue.

      The problem is with binding the combobox and checkbox. Can you help me how to bind this ?

      This is the existing code:
      Code:
      						<TR>
      							<TD>Specialist:</TD>
      							<TD>
      							<spring:bind path="orderForm.availableRoom[${roomCounter.index}].specialityCode">
      								<form:select path="${hotalRoom.specialityCode}"> 
      									<form:option value="0" label="Select"/>
      									<form:options items="${hotalRoom.allSpecialist}" itemValue="id"
      										itemLabel="value" />
      									</c:forEach>
      								 </form:select>
      							</spring:bind>
      							</TD>
      						</TR>
      						<TR>
      							<TD>Include breakfast ?</TD>
      							<TD>
      								<input type=checkbox name="${hotalRoom.breakfastYn}" value="Y"/>
      							</TD>
      						</TR>
      And I change this to normal display and it works.
      Code:
      						<TR>
      							<TD>Specialist:</TD>
      							<TD>
      								<select name="${hotalRoom.specialityCode}"> 
      									<option value="0">Select</option>
      									<c:forEach items="${hotalRoom.allSpecialist}" var="specCode">
      										<option value="${specCode.id}"><c:out value="${specCode.value}" 
      
      /></option>
      									</c:forEach>
      								 </select>
      							</TD>
      						</TR>
      						<TR>
      							<TD>Include breakfast ?</TD>
      							<TD>
      								<input type=checkbox name="${hotalRoom.breakfastYn}" value="Y"/>
      							</TD>
      						</TR>
      But I wn't able to retrive the values chosen.

      Please help me how to bind the <select> and the checkbox ?

      Thanks in advance.

      Comment


      • #4
        use only form: tags to bind your command object to the page, not spring:bind tags; plus, dont'use jstl $ in your path attributes... say OrderForm object has properties String specialityCode and List<Specialist> allSpecialist, and Specialist object has String id and String value, then:

        Code:
        <form:form commandName="orderForm">
            <form:select path="specialityCode"> 
        	<form:option value="0" label="Select"/>
        	<form:options items="allSpecialist" itemValue="id" itemLabel="value" />
            </form:select>
        </form:form>

        Comment


        • #5
          Thank you very much !

          I used only form:select and its working now !

          Comment

          Working...
          X