Results 1 to 8 of 8

Thread: Search and Display data on same page

  1. #1
    Join Date
    May 2007
    Posts
    10

    Default 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. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    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
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    May 2007
    Posts
    10

    Default

    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

  4. #4
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    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);
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  5. #5
    Join Date
    May 2007
    Posts
    10

    Default 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

  6. #6
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    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.
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  7. #7
    Join Date
    May 2007
    Posts
    10

    Smile Hi Peter

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

  8. #8
    Join Date
    Dec 2008
    Posts
    1

    Default

    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

Posting Permissions

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