Announcement Announcement Module
Collapse
No announcement yet.
Binding Lists Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding Lists

    I know there are many posts with the bind lists. I tried all the options but I am still getting the darn "Neither Errors instance nor plain target object for bean name 'bene' available as request attribute" .

    Can someone please help me with this:

    Here is my jsp:
    <c:forEach items="${model.beneData}" var="bene" varStatus="status">
    <spring:bind path="bene.get[${status.index}].claimNumber">
    <input type="hidden" name="claimNumber" value="<c:out .claimNumber}"/>" >
    </spring:bind>

    Here is my controller:

    public ModelAndView onSubmit(Object command,BindException errors)
    throws ServletException {

    String claimNumber = ((BeneFind) command).getClaimNumber();

    String now = (new java.util.Date()).toString();
    List beneData = getBeneManager().getBeneInfo(claimNumber);
    Map myModel = new HashMap();
    myModel.put("now", now);
    myModel.put("beneData", beneData);
    return new ModelAndView(getSuccessView(), "model", myModel);
    }

    protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    BeneFind benefind = new BeneFind();
    benefind.setClaimNumber("");
    return benefind;
    }

    I am trying to return to the same jsp page after updating:

    <property name="formView"><value>displayBene</value></property>
    <property name="successView"><value>displayBene</value></property>

  • #2
    Hi ishsn0

    Have you tried Spring MVC's secret handshake with regard to the ModelAndView, namely the BindException.getModel() method?

    Code:
    public ModelAndView onSubmit(Object command,BindException errors)
    throws ServletException {
        String claimNumber = ((BeneFind) command).getClaimNumber();
    
        String now = (new java.util.Date()).toString();
        List beneData = getBeneManager().getBeneInfo(claimNumber);
    
        Map myModel = errors.getModel();
        myModel.put("now", now);
        myModel.put("beneData", beneData);
        return new ModelAndView(getSuccessView(), "model", myModel);
    }
    Using the Map returned from BindException.getModel() will result in the command object being present in the model, which might address your address (unless of course it is some other issue, but this is a start).

    Ping the forum back if this does not resolve your issue.

    Cheers
    Rick

    Comment


    • #3
      Same result

      Hi Rick,

      Thank you for your speedy response. I did what you said:

      public ModelAndView onSubmit(Object command,BindException errors)
      throws ServletException {

      String claimNumber = ((BeneFind) command).getClaimNumber();

      String now = (new java.util.Date()).toString();
      List beneData = getBeneManager().getBeneInfo(claimNumber);

      Map myModel = errors.getModel();
      myModel.put("now", now);
      myModel.put("beneData", beneData);

      return new ModelAndView(getSuccessView(), "model", myModel );
      }

      And I still get the same error:
      "Neither Errors instance nor plain target object for bean name 'bene' available as request attribute"

      Comment


      • #4
        You are using the following in your jsp:

        <spring:bind path="bene.get[${status.index}].claimNumber">

        This is saying that your form controller command name is set to "bene". The "bene" object instance has a method named getGet() that returns a List that contains an object that has a setClaimNumber() method.

        Instead, I am guessing that you probably want to do the following:
        • Set your form controller command name to "beneData"
        • move "List beneData = getBeneManager().getBeneInfo(claimNumber);" to the formBackingObject method and return the List.
        • Iterate through ${beneData}
        • Make the spring bind tag path="beneData[${status.index}].claimNumber"

        Comment

        Working...
        X