Announcement Announcement Module
Collapse
No announcement yet.
Search and Display data on same page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Search and Display data on same page

    Hi,
    I am trying to do a search and display the results on the same page. When I try to do this I get the following error.
    Neither BindingResult nor plain target object for bean name 'faxstatusrequest' available as request attribute'

    Please find the below code of my configuration xml, controller and jsp page:

    <bean id="statusRequestController" class="com.ge.vsifaxstatus.controller.FaxStatusReq uestController">
    <property name="sessionForm"><value>true</value></property>
    <property name="commandName"><value>faxstatusrequest</value></property>
    <property name="commandClass"><value>com.ge.vsifaxstatus.bea n.FaxStatusRequest</value></property>
    <property name="validator"><ref bean="faxstatusRequestValidator"/></property>
    <property name="formView"><value>statusform</value></property>
    <property name="successView"><value>statusform</value></property>
    <property name="statusBO">
    <ref bean="statusRequestBO"></ref>
    </property>
    </bean>

    Here is my controller onSubmit method :
    String refId = ((FaxStatusRequest) command).getUsageId();
    FaxStatusRequest faxstatusrequest = ((FaxStatusRequest) command);
    logger.info("The service reference id is : " + refId );
    List statusList = statusBO.getFaxStatus(refId);
    //Map modelMap = errors.getModel();
    myModel.put("status",statusList);
    logger.info("returning from ModelAndView controller method : " + getSuccessView());
    return new ModelAndView("statusform","statusMap",myModel);

    And the jsp code is :

    <c:forEach items="${statusMap.status}" var="details">
    <table>
    <tr>
    <td class="textdisplay">Fax Number :</td>
    <td class="textdisplayBlack"><c:out value="${details.faxNumber}"/></td>
    </tr>

    I would appreciate any help.

    Thanks in advance.

  • #2
    hi

    String refId = ((FaxStatusRequest) command).getUsageId();
    try with
    Code:
    FaxStatusRequest faxStatusRequest = (FaxStatusRequest) command;
    String refId = faxStatusRequest.getUsageId();
    now in your jsp code i dont see the spring:nestedPath

    and use code tags to see better the code

    regards

    p.d. the examples in the spring distribution

    Comment


    • #3
      Thanks for the reply. I have changed the code as suggested but I still get an error.

      I am able to get the list from my query. But when I try to display that I get the following error.

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

      <spring:bind path="faxstatusrequest.usageId">
      <TD height="25" align="left" width="60%"><input type="text" class="tbl" name="usageId" value="<c:out value="${status.value}"/>"/></TD>
      </spring:bind>

      I am trying to display it on the same page thats when I get the error. It looks like it is unable to find my commandName in the request.

      I would appreciate your help.

      Thanks

      Comment


      • #4
        return new ModelAndView("statusform","statusMap",myModel);
        This constructor for ModelAndView is not likely to do what you want. Take a look at the superclass's onSubmit method to see what the default behavior is, and take a cue from that. Basically, you should be doing something like this:
        Code:
        Map model = errors.getModel();
        // ... add things to model (NOT the command object!)
        return new ModelAndView(getSuccessView(), model);

        Comment


        • #5
          Hi Peter

          Thanks so much for the reply. I have changed as you suggested and please find it below.

          String refId = ((FaxStatusRequest) command).getUsageId();
          FaxStatusRequest faxstatusrequest = ((FaxStatusRequest) command);
          logger.info("The service reference id is : " + refId );
          List statusList = statusBO.getFaxStatus(refId);
          Map modelMap = errors.getModel();
          modelMap.put("status",statusList);
          logger.info("returning from ModelAndView controller method : " + getSuccessView());
          return new ModelAndView("statusform",modelMap);

          The map object(modelMap) contains a list statusList which has a bean and number of properties associated with it. I have put the following code in the jsp to iterate the list.

          <c:forEach items="${modelMap.status}" var="details">
          <table>
          <tr><td class="textdisplay">Fax Number :</td>
          <td class="textdisplayBlack"><c:out value="${details.faxNumber}"/></td>
          </tr>
          <tr>
          <td class="textdisplay">Usage ID :</td>
          <td class="textdisplayBlack"><c:out value="${details.usageId}"/></td>
          </tr>
          <tr>
          <td class="textdisplay">Service Reference ID :</td>
          <td class="textdisplayBlack"><c:out value="${details.serviceReferenceId}"/></td>
          </tr>
          <tr>
          <td class="textdisplay">Fax Type:</td>
          <td class="textdisplayBlack"><c:out value="${details.masterTypeDescription}"/> type</td>
          </tr>
          When I run the application I get the page with form (atleast the error is gone) but the data does not display. Is the way I am iterating right or wrong?
          I would appreciate your help.

          Thanks

          Comment


          • #6
            It's incorrect. The "modelMap" you reference in the JSP page isn't the name of anything in the model you're passing to the ModelAndView. Since you're explicitly adding the list of status elements using the model name "status", simply change the items attribute of your loop to:
            Code:
            <c:forEach items="${status}" var="details">
            This should get you closer. I'd strongly suggest going through some of the samples, i.e. petclinic, to see how working code gets put together, and/or read some of the excellent documentation in the Spring 2 docs relating to the Web/MVC parts of Spring.

            Comment


            • #7
              Hi Peter

              It really worked and you saved my day . Thanks so much guys.

              Comment


              • #8
                Hi

                I changed my according to above and decleared a variable of errors of type modeland view .

                Still getting error like this

                exception

                org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is java.lang.NullPointerException
                org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:583)
                org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511)
                javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
                javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


                root cause

                java.lang.NullPointerException
                com.spring.controller.UserDetailController.onSubmi t(UserDetailController.java:56)
                org.springframework.web.servlet.mvc.SimpleFormCont roller.onSubmit(SimpleFormController.java:409)
                org.springframework.web.servlet.mvc.SimpleFormCont roller.onSubmit(SimpleFormController.java:381)
                org.springframework.web.servlet.mvc.SimpleFormCont roller.processFormSubmission(SimpleFormController. java:267)
                org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestInternal(AbstractFormControl ler.java:265)
                org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:153)
                org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
                org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:875)
                org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:809)
                org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
                org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511)
                javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
                javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

                Plz suggest me how to overcome this error.....

                Thanks in advance.

                Yuva

                Comment

                Working...
                X